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

GATE 2007

184 questions

MCQ 1841-mark 184

Questions 131–135 of 184

Q131Process Synchronization1 markMCQ−0.33 if wrong
Synchronization in the classical readers and writers problem can be achieved through use of semaphores. In the following incomplete code for readers-writers problem, two binary semaphores mutex and wrt are used to obtain synchronization
wait (wrt)
writing is performed
signal (wrt)
wait (mutex)  
readcount = readcount + 1
if readcount = 1 then S1
S2
reading is performed
S3
readcount = readcount - 1
if readcount = 0 then S4 
signal (mutex) 

The values of S1, S2, S3, S4, (in that order) are

Q132Process Synchronization1 markMCQ−0.33 if wrong
Processes P1 and P2 use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program.
 get_exclusive_access ( )
{
    if (critical _flag == FALSE) {
        critical_flag = TRUE ;
        critical_region () ;
        critical_flag = FALSE;
    }
}

Consider the following statements.

i.It is possible for both P1 and P2 to access critical_region concurrently.
ii.This may lead to a deadlock.

Which of the following holds?

Q133Process Synchronization1 markMCQ−0.33 if wrong
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:
/* P1 */                        /* P2 */
while (true) {                  while (true) {
   wants1 = true;                  wants2 = true;
   while (wants2==true);           while (wants1==true);
   /* Critical                     /* Critical
      Section */                      Section */
   wants1=false;                   wants2=false;
}                               }
/* Remainder section */         /* Remainder section */

Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?

Q134Deadlock1 markMCQ−0.33 if wrong
A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?
allocrequest XYZXYZ P0121103 P1201012 P2221120

Q135CPU Scheduling1 markMCQ−0.33 if wrong
An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes:
 Process  Execution time  Arrival time
P1             20            0
P2             25            15
P3             10            30
P4             15            45
What is the total waiting time for process P2?