Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

COS3721 Assignment 2 (COMPLETE ANSWERS) 2026 - DUE 1 July 2026

Puntuación
-
Vendido
-
Páginas
19
Grado
A+
Subido en
30-06-2026
Escrito en
2025/2026

COS3721 Assignment 2 (COMPLETE ANSWERS) 2026 - DUE 1 July 2026; 100% TRUSTED Complete, trusted solutions and explanations. For assistance, Whats-App 0.8.1..2.7.8..3.3.7.2... Ensure your success with us...... Question 01 [15 marks] You are designing an operating system for a new server with 8 processor cores. The server will run a mix of CPU-intensive tasks (e.g., video encoding) and short interactive tasks (e.g., handling user requests). The OS team is debating between two scheduling approaches: • Per-core run queues: Each core maintains its own queue of ready processes. • Shared run queue: All cores take tasks from a single global queue. a. Explain how each approach schedules CPU-intensive and short interactive tasks. (4) b. List at least two advantages and two disadvantages for each scheduling approach. (6) c. Suppose that some cores are idle while others are overloaded. Which approach would make it easier to balance the workload, and why? (2) d. Recommend one approach for this server, and justify your choice based on performance, cache usage, and fairness. (3) Question 02 [15 marks] Consider the following set of processes, with their priority, burst time, and arrival time. A higher numerical priority indicates a higher priority. • If multiple processes have the same priority, use round-robin scheduling with a time quantum of 8 units. • If a higher-priority process arrives while another is executing, the running process is preempted and placed at the end of the queue. Process Priority Burst Arrival P1 6 18 0 P2 4 12 0 P3 5 15 10 P4 5 10 12 P5 7 8 20 P6 3 20 25 a. Draw a Gantt chart showing the scheduling order of the processes by indicating preemptions and time quantum usage clearly. (5) 6 b. Calculate the turnaround time for each process. Present your answer in a table with the following headings: Process | Arrival Time | Completion Time | Turnaround Time. (5) c. Calculate the waiting time for each process. Present your answer in a table with the following headings: Process | Burst | Turnaround Time | Waiting Time. (5) Notes: • Preemption: If a process with higher priority arrives, the running process is preempted and placed at the end of the queue. • Round-Robin: If multiple processes have the same priority, execute them cyclically using the time quantum of 8 units. Question 03 [10 marks] Assume two tasks, A and B, are running on a Linux system using the Completely Fair Scheduler (CFS). The nice values of the tasks are: • Task A: −5 (higher priority) • Task B: +5 (lower priority) The virtual runtime (vruntime) in CFS increases proportionally to the inverse of the task’s weight, and a smaller vruntime means the task is more likely to be scheduled next. Answer the following scenarios, explaining how the vruntime of each task behaves relative to the other: 1. Both A and B are CPU-bound. 2. A is I/O-bound, and B is CPU-bound. 3. A is CPU-bound, and B is I/O-bound. For each scenario: a. Describe qualitatively how the vruntime of A and B changes over time. (5) b. Indicate which task is likely to be scheduled more often. (5) Hints: • CPU-bound tasks always use CPU when scheduled; I/O-bound tasks sleep often. • Higher-weight tasks (lower nice value) accumulate vruntime slower. • CFS favours tasks with smaller vruntime. COS3721/102/0/2026 7 Question 04 [10 marks] Two processes, P1 and P2, share a counting semaphore sem initialized to 1. A developer decides to optimize the code by first checking the semaphore value before calling wait(), as shown below: if (getValue(&sem) 0) wait(&sem); a. Explain why checking the semaphore value before calling wait() is unsafe in a concurrent environment. (3) b. Describe a scenario (with P1 and P2) in which both processes intend to enter the critical section but may experiencing race conditions or unexpected blocking due to this approach. (5) c. Propose a safer alternative that prevents blocking while ensuring proper mutual exclusion. (2) Question 05 [10 marks] Consider designing a mutex lock for synchronizing concurrent threads using the atomic compare_and_swap() instruction. Assume the following lock structure is provided: typedef struct { int available; // 0 = unlocked, 1 = locked } lock; a. Explain how you would initialize this mutex to ensure it is ready for use. (2) b. Using compare_and_swap(), implement the acquire function that ensures mutual exclusion without race conditions. (4) c. Implement the release function that safely unlocks the mutex. (2) d. Discuss why compare_and_swap() is critical in preventing race conditions in your implementation. (2) Question 06 [12 marks] Modern operating systems such as Windows and Linux provide multiple types of locking mechanisms to manage concurrency. Imagine a multi-threaded server handling thousands of client requests. Threads need to access shared resources, perform I/O operations, and coordinate with each other. a. Explain why operating systems implement multiple types of locks instead of a single universal lock. (4) 8 b. For each of the following mechanisms - spinlocks, mutex locks, semaphores, and condition variables - describe: (8) • A situation or scenario in which the mechanism would be used. • Why it is needed in that scenario. Question 07 [8 marks] A database server allows multiple clients to read or write shared records. To optimize performance • Multiple clients can read simultaneously. • Only one client can write at a time, and no readers can access the data during writing. A company wants to implement a version of the Readers-Writers problem where writers are given priority over readers to prevent writer starvation and readers should not be blocked unnecessarily if no writers are waiting. a. Explain the problem that could occur if reader threads are always given priority over writers. Focus on how this affects writers. (2) b. Propose a synchronization strategy to ensure writer priority while allowing concurrent reading when possible. Provide your answer in concise bullet points, addressing: 1. Required synchronization variables (2) 2. How multiple readers can read concurrently (2) 3. How writers obtain exclusive access (2) 4. How writer starvation is prevented (4) c. Complete the timeline table below to show how readers and writers interact under your synchronization strategy. For each process at each time step, indicate: enters, reading, writing, waiting, blocked, or exits. Some cells may remain empty if the process is not active. Note: “Assume the system follows the writer-priority Readers–Writers solution discussed in part b.” (6) Time Reader R1 Reader R2 Writer W1 Reader R3 t0 enters t1 reading enters t2 reading reading arrives t3 t4 t5 t6 COS3721/102/0/2026 9 Question 08 [10 marks] In operating systems, race conditions occur whenever multiple threads or processes read and write shared data concurrently without proper synchronization. Using mutexes, spinlocks, or atomic operations prevents these inconsistencies in kernel data structures. a. Identify two kernel data structures that are susceptible to race conditions. (4) b. For each, describe a scenario showing how a race condition can occur. (6)

Mostrar más Leer menos
Institución
Grado

Vista previa del contenido

COS3721
Assignment 2 2026
Unique number:
Due Date: June 2026

QUESTION 01

a. How each approach schedules CPU-intensive and short interactive tasks

In the per-core run queue approach, each processor core has its own ready queue, so
tasks are placed on a specific core and that core selects tasks only from its own queue.
CPU-intensive tasks, such as video encoding, may continue running on the same core for
long periods, which can improve cache use because the process often reuses data already
stored close to that core. Short interactive tasks are also placed in one of the core queues,
but their response time may suffer if they are placed behind long CPU-intensive tasks on a
busy core.

In the shared run queue approach, all ready processes are kept in one global queue, and
any free processor core can take the next available task from that queue. CPU-intensive
tasks are selected from the same queue as interactive tasks, so the system can spread work
across all eight cores more easily. Short interactive tasks may get quicker attention because
an idle core can take them directly from the global queue instead of waiting for one specific
Terms of use
overloaded core to finish its work. The question in TL102 asks this in the context of an eight-
By making use of this document you agree to:
core server  Use this document
that runs both CPU-intensive as a guide
and short for learning,
interactive comparison and reference purpose,
tasks.
Terms of use
 Not to duplicate, reproduce and/or misrepresent the contents of this document as your own work,
By making use of this document you agree to:
 Use this document
Fully accept the consequences
solely as a guide forshould you plagiarise
learning, or and
reference, misuse this document.
comparison purposes,
 Ensure originality of your own work, and fully accept the consequences should you plagiarise or misuse this document.
 Comply with all relevant standards, guidelines, regulations, and legislation governing academic and written work.

Disclaimer
Great care has been taken in the preparation of this document; however, the contents are provided "as is" without any express or
implied representations or warranties. The author accepts no responsibility or liability for any actions taken based on the
information contained within this document. This document is intended solely for comparison, research, and reference purposes.
Reproduction, resale, or transmission of any part of this document, in any form or by any means, is strictly prohibited.

, +27 81 278 3372



QUESTION 01

a. How each approach schedules CPU-intensive and short interactive tasks

In the per-core run queue approach, each processor core has its own ready queue,
so tasks are placed on a specific core and that core selects tasks only from its own
queue. CPU-intensive tasks, such as video encoding, may continue running on the
same core for long periods, which can improve cache use because the process often
reuses data already stored close to that core. Short interactive tasks are also placed
in one of the core queues, but their response time may suffer if they are placed
behind long CPU-intensive tasks on a busy core.

In the shared run queue approach, all ready processes are kept in one global
queue, and any free processor core can take the next available task from that queue.
CPU-intensive tasks are selected from the same queue as interactive tasks, so the
system can spread work across all eight cores more easily. Short interactive tasks
may get quicker attention because an idle core can take them directly from the global
queue instead of waiting for one specific overloaded core to finish its work. The
question in TL102 asks this in the context of an eight-core server that runs both
CPU-intensive and short interactive tasks.

b. Advantages and disadvantages of each scheduling approach


Scheduling Advantages Disadvantages
approach


Per-core It improves cache performance Some cores can become
run queues because a process can remain overloaded while other cores
on the same core and reuse remain idle if tasks are not moved
cached data. It also reduces properly. It can also be less fair
contention because each core because a short task may wait
manages its own queue instead behind long CPU-bound tasks in
of many cores fighting for one one queue while another core is
shared queue. free.


Disclaimer
Great care has been taken in the preparation of this document; however, the contents are provided "as is"
without any express or implied representations or warranties. The author accepts no responsibility or
liability for any actions taken based on the information contained within this document. This document is
intended solely for comparison, research, and reference purposes. Reproduction, resale, or transmission
of any part of this document, in any form or by any means, is strictly prohibited.

, +27 81 278 3372




Shared run It gives better load balancing It can create contention because all
queue because all cores take tasks cores must access the same
from the same global queue. It queue, especially on a busy server.
can also improve fairness It can also reduce cache
because all ready tasks are performance because a process
visible to the scheduler in one may move between cores and lose
place. the benefit of data already cached
on one core.


c. Easier workload balancing

The shared run queue approach makes workload balancing easier because all
eight cores draw work from the same global queue. When one core becomes idle, it
can immediately take the next ready task without needing to steal work from another
core’s private queue. This avoids the problem where one core has many waiting
tasks while another core has nothing to do.

d. Recommended approach

For this server, I would recommend per-core run queues with load balancing,
rather than a purely shared run queue. This approach is better for performance
because each core can schedule its own tasks with less locking and less contention.
It also supports better cache usage because CPU-intensive tasks can stay on the
same core and continue using data already stored in that core’s cache. Fairness can
still be protected if the operating system includes periodic load balancing, where
tasks are moved from overloaded cores to idle or less busy cores.

A shared run queue is simpler for balancing work, but it may become a bottleneck
when many cores try to access the same queue at the same time. Since the server
has eight processor cores and must handle both long CPU-intensive work and short
user requests, per-core queues with proper task migration give a stronger balance
between speed, cache efficiency and fair access to CPU time.




Disclaimer
Great care has been taken in the preparation of this document; however, the contents are provided "as is"
without any express or implied representations or warranties. The author accepts no responsibility or
liability for any actions taken based on the information contained within this document. This document is
intended solely for comparison, research, and reference purposes. Reproduction, resale, or transmission
of any part of this document, in any form or by any means, is strictly prohibited.

Libro relacionado

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
30 de junio de 2026
Número de páginas
19
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$4.76
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
EduPal University of South Africa (Unisa)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
153064
Miembro desde
7 año
Número de seguidores
36023
Documentos
4932
Última venta
1 hora hace

At EduPal we provide academic assistance, exam preparation, detailed notes, and exam packs to help college students study with confidence. Our tutoring is comprehensive and personalised, focusing on your subject needs and deadlines. We guarantee quality support, clear guidance, and proven strategies that improve understanding, marks, and pass rates. For more information Whats-App 0.8.1..2.7.8..3.3.7.2..

4.2

14230 reseñas

5
8258
4
2780
3
1863
2
484
1
845

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes