• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

OS Process Management

Question 31

The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1() 
{ 
   C = B – 1; 
   B = 2*C;  
}

P2()
{
   D = 2 * B;
   B = D - 1; 
}
The number of distinct values that B can possibly take after the execution is
  • 3
  • 2
  • 5
  • 4

Question 32

Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes. Q20 Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?
  • The proposed solution prevents deadlock but fails to guarantee mutual exclusion
  • The proposed solution guarantees mutual exclusion but fails to prevent deadlock
  • The proposed solution guarantees mutual exclusion and prevents deadlock
  • The proposed solution fails to prevent deadlock and fails to guarantee mutual exclusion

Question 33

In a certain operating system, deadlock prevention is attempted using the following scheme. Each process is assigned a unique timestamp, and is restarted with the same timestamp if killed. Let Ph be the process holding a resource R, Pr be a process requesting for the same resource R, and T(Ph) and T(Pr) 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?
  • The scheme is deadlock-free, but not starvation-free
  • The scheme is not deadlock-free, but starvation-free
  • The scheme is neither deadlock-free nor starvation-free
  • The scheme is both deadlock-free and starvation-free

Question 34

A process executes the following segment of code :
 for(i = 1; i < = n; i++)

fork (); 
The number of new processes created is  
  • n
  • ((n(n + 1))/2)
  • 2n - 1
  • 3n - 1

Question 35

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 Prepeatedly 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
  • P(full), V(empty), P(full), V(empty)
  • P(full), V(empty), P(empty), V(full)
  • P(empty), V(full), P(empty), V(full)
  • P(empty), V(full), P(full), V(empty)

Question 36

Consider the following two-process synchronization solution.
Process 0                             Process 1                          

Entry: loop while (turn == 1);        Entry: loop while (turn == 0);
       (critical section)                    (critical section)
       Exit: turn = 1;                       Exit turn = 0; 

The shared variable turn is initialized to zero. Which one of the following is TRUE?
  • This is a correct two-process synchronization solution.
  • This solution violates mutual exclusion requirement.
  • This solution violates progress requirement.
  • This solution violates bounded wait requirement.

Question 37

Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.
  • 7
  • 8
  • 9
  • 10

Question 38

In the working-set strategy, which of the following is done by the operating system to prevent thrashing?
  1. It initiates another process if there are enough extra frames.
  2. It selects a process to suspend if the sum of the sizes of the working-sets exceeds the total number of available frames.
 
  • I only
  • II only
  • Neither I nor II
  • Both I and II

Question 39

The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V operations. semaphore S = 1, Q = 0; integer x; producer:                            consumer: while (true) do                    while (true) do P(S);                                      P(Q); x = produce ();                    consume (x); V(Q);                                     V(S); done                                       done Which of the following is TRUE about the program above?
  • The process can deadlock
  • One of the threads can starve
  • Some of the items produced by the producer may be lost
  • Values generated and stored in \'x\' by the producer will always be consumed before the producer can generate a new value

Question 40

An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:

  • Both starvation and deadlock can occur

  • Starvation can occur but deadlock cannot occur

  • Starvation cannot occur but deadlock can occur

  • Neither starvation nor deadlock can occur

There are 115 questions to complete.

Last Updated :
Take a part in the ongoing discussion