GATEverse
← GATE CSE 2001

Q19

MCQMarks unknown

Two concurrent processes P1P1 and P2P2 want to use resources R1R1 and R2R2 in a mutually exclusive manner. Initially, R1R1 and R2R2 are free. The programs executed by the two processes are given below.

Program for P1:Program for P2:S1:While (R1 is busy) do no-op;Q1:While (R1 is busy) do no-op;S2:Set R1 ← busy;Q2:Set R1 ← busy;S3:While (R2 is busy) do no-op;Q3:While (R2 is busy) do no-op;S4:Set R2 ← busy;Q4:Set R2 ← busy;S5:Use R1 and R2;Q5:Use R1 and R2;S6:Set R1 ← free;Q6:Set R2 ← free;S7:Set R2 ← free;Q7:Set R1 ← free;\begin{array}{|ll|ll|}\hline & \textbf{Program for P1:} && \textbf{Program for P2:} \\\hline \text{S1:} & \text{While ($R1$ is busy) do no-op;} & \text{Q1:} & \text{While ($R1$ is busy) do no-op;} \\ \text{S2:} & \text{Set $R1$ $\leftarrow$ busy;} & \text{Q2:} & \text{Set $R1$ $\leftarrow$ busy;} \\ \text{S3:} & \text{While ($R2$ is busy) do no-op;} & \text{Q3:} & \text{While ($R2$ is busy) do no-op;} \\ \text{S4:} & \text{Set $R2$ $\leftarrow$ busy;} & \text{Q4:} & \text{Set $R2$ $\leftarrow$ busy;} \\ \text{S5:} & \text{Use $R1$ and $R2$;} & \text{Q5:} & \text{Use $R1$ and $R2$;} \\ \text{S6:} & \text{Set $R1$ $\leftarrow$ free;} & \text{Q6:} & \text{Set $R2$ $\leftarrow$ free;} \\ \text{S7:} & \text{Set $R2$ $\leftarrow$ free;} & \text{Q7:} & \text{Set $R1$ $\leftarrow$ free;} \\\hline \end{array}
Sign in to save attempts.

Loading…