GATE 2005 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2005

203 questions

MCQ 2031-mark 203

Questions 151–155 of 203

Q151Process Synchronization1 markMCQ−0.33 if wrong
Two concurrent processes P1 and P2 use four shared resources R1, R2, R3 and R4, as shown below.
P1P2Compute: Compute;Use R1; Use R1;Use R2; Use R2;Use R3; Use R3;Use R4; Use R4;\begin{array}{|l|l|}\hline \textbf{P1} & \textbf{P2} \\ \text{Compute: } & \text{Compute;} \\ \text{Use $R1;$ } & \text{Use $R1;$} \\ \text{Use $R2;$ } & \text{Use $R2;$}\\ \text{Use $R3;$ } & \text{Use $R3;$} \\ \text{Use $R4;$ } & \text{Use $R4;$} \\\hline \end{array}
Both processes are started at the same time, and each resource can be accessed by only one process at a time The following scheduling constraints exist between the access of resources by the processes:
P2 must complete use of R1 before P1 gets access to R1.
P1 must complete use of R2 before P2 gets access to R2.
P2 must complete use of R3 before P1 gets access to R3.
P1 must complete use of R4 before P2 gets access to R4.
There are no other scheduling constraints between the processes. If only binary semaphores are used to enforce the above scheduling constraints, what is the minimum number of binary semaphores needed?

Q152Process Synchronization1 markMCQ−0.33 if wrong
Given below is a program which when executed spawns two concurrent processes :
semaphore X : = 0 ;
/* Process now forks into concurrent processes P1 & P2 */
P1P2repeat forever repeat foreverV(X); P(X);Compute; Compute;P(X); V(X);\begin{array}{|l|l|}\hline \text{$P1$} & \text{$P2$} \\\hline \text{repeat forever } & \text{repeat forever} \\ \text{$V (X) ;$ } & \text{$ P(X) ;$} \\ \text{Compute; } & \text{Compute;}\\ \text{$P(X) ;$ } & \text{$V(X) ;$} \\\hline \end{array}
Consider the following statements about processes P1 and P2:
I.It is possible for process P1 to starve.
II.It is possible for process P2 to starve.
Which of the following holds?

Q153Deadlock1 markMCQ−0.33 if wrong
Two shared resources R1R_1 and R2R_2 are used by processes P1P_1 and P2P_2. Each process has a certain priority for accessing each resource. Let TijT_{ij} denote the priority of PiP_i for accessing RjR_j. A process PiP_i can snatch a resource RkR_k from process PjP_j if TikT_{ik} is greater than TjkT_{jk}.
Given the following :

(I). T11>T21T_{11} \gt T_{21}
(II). T12>T22T_{12} \gt T_{22}
(III). T11<T21T_{11} \lt T_{21}
(IV). T12<T22T_{12} \lt T_{22}

Which of the following conditions ensures that P1P_1 and P2P_2 can never deadlock?

Q154Deadlock1 markMCQ−0.33 if wrong
Suppose n processes, P1,...,PnP_1,..., P_n share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process PiP_i is sis_i, where si>0s_i \gt 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?
(a)i, si < m (b)i, si < n (c) ∑ ni=1 si < (m + n) (d) ∑ ni=1 si < (m * n)

Q155CPU Scheduling1 markMCQ−0.33 if wrong
We wish to schedule three processes P1, P2 and P3 on a uniprocessor system. The priorities, CPU time requirements and arrival times of the processes are as shown below.
ProcessPriorityCPU timeArrival timerequired(hh:mm:ss)P110 (highest)20 sec00:00:05P2910 sec00:00:03P38 (lowest)15 sec00:00:00\begin{array}{|c|c|c|c|} \hline \textbf{Process} & \textbf{Priority} & \textbf{CPU time} & \textbf{Arrival time}\\ & & \textbf{required} & \textbf{(hh:mm:ss)} \\\hline \text{P1} & \text{10 (highest)} & 20\text{ sec} & 00:00:05 \\\hline \text{P2} & 9 & 10 \text{ sec}& 00:00:03 \\\hline \text{P3} & \text{8 (lowest)} & 15 \text{ sec}& 00:00:00 \\\hline \end{array}
We have a choice of preemptive or non-preemptive scheduling. In preemptive scheduling, a late-arriving higher priority process can preempt a currently running process with lower priority. In non-preemptive scheduling, a late-arriving higher priority process must wait for the currently executing process to complete before it can be scheduled on the processor.
What are the turnaround times (time from arrival till completion) of P2 using preemptive and non-preemptive scheduling respectively?