GATE Exam Questions on Concurrency and Scheduling
GATE Exam Questions on Concurrency and Scheduling
REQ1 can be safely permitted as it requests 0 units of X, 0 units of Y, and 2 units of Z, which are within the available limit, keeping the system in a safe state. REQ2, requesting 2 units of X (exceeding available resources), cannot be granted without risking the system's safety. The system must ensure that satisfying a request leaves enough resources for future requests to maintain safety .
The pre-emptive shortest job first scheduling algorithm selects the process with the smallest burst time from the ready queue, leading to frequent context switching. For processes P0, P1, and P2, with arrival times of 0 ms, 1 ms, and 2 ms respectively, the processes are scheduled such that P1 finishes first due to its shorter burst time, followed by P2 and then P0. The average waiting time for all processes is therefore 6.33 ms .
A deadlock is possible if each process reaches a state where it holds some resources and waits for others held by other processes, causing a cyclical wait condition. For instance, when n=40 and k=26, if processes occupy resources creating circular dependencies (like odd-index processes requesting resources in a manner conflicting with even-index processes), a deadlock can occur as the condition for a circular wait among resources is met .
Aborting process P3 makes the system deadlock free by breaking the cycle of dependent processes needing resources already held by others, hence resolving the circular wait condition. In the resource allocation graph, removing P3 disrupts the claim dependency loop, thereby ensuring other processes can proceed and acquire necessary resources without deadlock .
In FCFS, processes are executed in order of their arrival times, with P1 arriving first, leading to completion order P1, P2, P3 . For Round Robin with a quantum of 2 time units, processes are time-sliced, resulting in frequent context switching. This scheduling results in the completion order P1, P3, P2 due to preemption after quantum expiration, allowing P3 to complete before P2 due to shorter burst time when using RR2 .
The Fetch_And_Add instruction reads the current value of a memory location, increments it, and returns the initial value, allowing the implementation of busy-wait locks by indicating whether the lock is available (0) or not available (non-zero). However, the implementation can lead to process starvation because processes could potentially be waiting indefinitely if they continuously try to acquire the lock while others are holding it .
The correct implementation is ExitX(R, S) with operations P(S); V(R) and EntryY(R, S) with operations P(R); V(S). This order ensures that Process X completes its task and signals Process Y to proceed, maintaining the dependency order for computing arrays a and b effectively and ensuring proper synchronization between them .
Different page replacement policies manage memory differently, leading to varied numbers of page faults. The Optimal replacement algorithm results in 7 page faults for the given reference string and page frame count, as it replaces the page that will not be used for the longest time in the future, minimizing faults and increasing efficiency compared to policies like Least Recently Used or Least Frequently Used which might have higher fault rates in certain sequences .
In Round Robin scheduling, the time slice determines how long processes can run before being preempted. If there are n processes with time slice q, a process experiences a delay of up to (n-1)×q units before executing again, affecting its turnaround time and response time. This mechanism ensures fair CPU time distribution but may lead to higher context switch overhead with more processes .
In contiguous allocation, the maximum file size on a disk with a block size of 1KB and total disk capacity of 1GB is equal to the whole disk size if one file takes the entire space without fragmentation, thus 1GB . This strategy requires enough contiguous free space for file storage, thus affecting allocation efficiency and possibly leading to external fragmentation.