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

GATE 2004

199 questions

MCQ 1991-mark 199

Questions 136–140 of 199

Q136Process Synchronization1 markMCQ−0.33 if wrong
The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process P2 repeatedly removes one item at a time from the same buffer using the programs given below. In the programs, K, L, M and N are unspecified statements.
P1
 while (1) {
    K;
    P(mutex);
    Add an item to the buffer;
    V(mutex);
    L;
}

P2
while (1) {
    M;
    P(mutex);
    Remove an item from the buffer;
    V(mutex);
    N;
} 

The statements K, L, M and N are respectively

Q137Process Synchronization1 markMCQ−0.33 if wrong
Consider two processes P1 and P2 accessing the shared variables X and Y protected by two binary semaphores Sx and Sy respectively, both initialized to 1. P and V denote the usual semaphore operators, where P decrements the semaphore value, and V increments the semaphore value. The pseudo-code of P1 and P2 is as follows:
P1
 While true do {
   L1 : ................
   L2 : ................
   X = X + 1;
   Y = Y - 1;
   V(Sx);
   V(Sy);             
 }

P2
 While true do {
   L3 : ................   
   L4 : ................
   Y = Y + 1;
   X = Y - 1;
   V(Sy);
   V(Sx);            
}
In order to avoid deadlock, the correct operators at L1 , L2 , L3 and L4 are respectively.

Q138Deadlock1 markMCQ−0.33 if wrong
In a certain operating system, deadlock prevention is attemped using the following scheme. Each process is assigned a unique timestamp, and is restarted with the same timestamp if killed. Let PhP_h be the process holding a resource R, PrP_r be a process requesting for the same resource R, and T(PhP_h) and T(PrP_r) be their timestamps respectively. The decision to wait or preempt one of the processes is based on the following algorithm.
 if T(Pr) < T(Ph) then 
    kill Pr 
else wait
Which one of the following is TRUE?

Q139CPU Scheduling1 markMCQ−0.33 if wrong
Consider the following set of processes, with the arrival times and the CPU-burst times given in milliseconds.
Process Arrival time Burst time P1 0 5 P2 1 3 P3 2 3 P4 4 1
What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm?

Q140Disk Scheduling1 markMCQ−0.33 if wrong
A disk has 200 tracks (numbered 0 through 199). At a given time, it was servicing the request of reading data from track 120, and at the previous request, service was for track 90. The pending requests (in order of their arrival) are for track numbers.

30 70 115 130 110 80 20 25.

How many times will the head change its direction for the disk scheduling policies SSTF(Shortest Seek Time First) and FCFS (First Come First Serve)?