GATE 2010
82 questions
MCQ 821-mark 39 · 2-mark 43
Questions 46–50 of 82
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0.
How many times will process P0 print '0'?
| Process P0 | Process P1 | Process P2 |
| | |
How many times will process P0 print '0'?
Answer: (A)
P0 prints '0' once at first, because S0 = 1. Then it releases S1 and S2. After that, P1 and P2 each release S0 one time.
- Case 1: both releases happen before P0 waits again. Binary S0 stays at 1 P0 prints one more time (2 times in all).
- Case 2: P0 takes the first release before the second one comes P0 prints two more times (3 times in all).
So P0 prints at least twice.
Answer: At least twice
- Case 1: both releases happen before P0 waits again. Binary S0 stays at 1 P0 prints one more time (2 times in all).
- Case 2: P0 takes the first release before the second one comes P0 prints two more times (3 times in all).
So P0 prints at least twice.
Answer: At least twice
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.
Which one of the following statements describes the properties achieved?
| Method used by P1 | Method used by P2 |
| |
Which one of the following statements describes the properties achieved?
Answer: (A)
P1 goes into its critical section only when S1 S2. After that, it makes the two values equal. P2 goes in only when S1 = S2. After that, it makes the two values unequal.
- P1 and P2 can never be inside together so mutual exclusion holds.
- The two must take turns strictly. If it is P1's turn but P1 does not want to enter, P2 waits forever so there is no progress.
Answer: Mutual exclusion but not progress
- P1 and P2 can never be inside together so mutual exclusion holds.
- The two must take turns strictly. If it is P1's turn but P1 does not want to enter, P2 waits forever so there is no progress.
Answer: Mutual exclusion but not progress
A system has n resources , and k processes . The implementation of the resource request logic of each process is as follows:
if (i%2= = 0) {
if (in) request ;
if (i+2n)request ;
}
else {
if (in) request ;
if (i+2n)request ;
} In which one of the following situations is a deadlock possible?Answer: (B)
A deadlock needs an even process i that holds and waits for . At the same time, an odd process j must hold and wait for . So j = n i 2 has to be odd, and both i and j must be k.
- n = 21, k = 12: i = 8 and j = 11 work deadlock is possible.
- n = 40 or n = 20: j = n i 2 is even not possible.
- n = 41, k = 19: i + j = 39, so one of them must be 20 not possible.
Answer: n = 21, k = 12
- n = 21, k = 12: i = 8 and j = 11 work deadlock is possible.
- n = 40 or n = 20: j = n i 2 is even not possible.
- n = 41, k = 19: i + j = 39, so one of them must be 20 not possible.
Answer: n = 21, k = 12
Which of the following statements are true?
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
Answer: (D)
Let us check every statement:
- I: If short jobs keep coming, long jobs may have to wait forever True
- II: In preemptive priority scheduling, low-priority processes can starve True
- III: RR lets each process get the CPU soon, so its response time is better than FCFS True
Answer: I, II and III
- I: If short jobs keep coming, long jobs may have to wait forever True
- II: In preemptive priority scheduling, low-priority processes can starve True
- III: RR lets each process get the CPU soon, so its response time is better than FCFS True
Answer: I, II and III
A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system first accesses 100 distinct pages in some order and then accesses the same 100 pages but now in the reverse order. How many page faults will occur?
Answer: (A)
In the first pass, all 100 pages fault, so that is 100 faults. The frames then hold pages 97, 98, 99, 100.
In the reverse pass, pages 100, 99, 98, 97 are hits. The other 96 pages all fault.
Total = 100 + 96 = 196
Answer: 196
In the reverse pass, pages 100, 99, 98, 97 are hits. The other 96 pages all fault.
Total = 100 + 96 = 196
Answer: 196