Assignment 2
Assignment 2
ASSIGNMENT#2
Registration No SP20-BSE-046
Class Section A
Answer: A process control block (PCB) is a data structure used by computer operating systems to
store all the information about a process. It is also known as a process descriptor. When a process is
created (initialized or installed), the operating system creates a corresponding process control block.
During context switch, the running process is stopped and another process runs. The kernel must
stop the execution of the running process, copy out the values in hardware registers to its PCB, and
update the hardware registers with the values from the PCB of the new process.
Q2: Compare SJF preemptive and Round robin with time quantum 3 for scheduling
processes that are provided below and analyze which algorithm executes maximum number
of processes in 15 cycles. Also calculate the waiting and turnaround times for each process.
Compute the average waiting and turnaround time for both scheduling algorithms.
P1 9 0
P2 7 2
P3 4 3
P4 5 5
P5 3 6
Q3: How Readers-writer problem can be solved using mutex locks and semaphores?
As the hardware solution is not easy to implement for everyone, a strict software approach called
Mutex Locks was introduced. In this approach, in the entry section of code, a LOCK is acquired over
the critical resources modified and used inside critical section, and in the exit section that LOCK is
released.
As the resource is locked while a process executes its critical section hence no other process can
access it.
It is a significant technique for managing concurrent processes by using the value of a simple integer
variable to synchronize the progress of interacting processes.So it is basically a synchronizing
tool and is accessed only through two low standard atomic operations, wait and signal designated
by P(S) and V(S) respectively.
In very simple words, semaphore is a variable which can hold only a non-negative Integer value,
shared between all the threads, with operations wait and signal.
i. Wait: Decrements the value of its argument S, as soon as it would become non-negative(greater
than or equal to 1).
ii. Signal: Increments the value of its argument S, as there is no more process blocked on the queue.