Operating systems miscellaneous


Operating systems miscellaneous

  1. Which of the following is not a valid deadlock prevention scheme?









  1. View Hint View Answer Discuss in Forum

    In deadlock prevention scheme, The operating system requests a resource after releasing the resource held by him, if needed. This is not a condition that a process cannot request a resource.

    Correct Option: C

    In deadlock prevention scheme, The operating system requests a resource after releasing the resource held by him, if needed. This is not a condition that a process cannot request a resource.


  1. Suppose n processes, p1, p2..., pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?









  1. View Hint View Answer Discuss in Forum

    For every Pi Si is maximum resource requirement where Si > 0. To allot resources to all processes without any deadlock situation is

    i.e. sum of all maximum resource requirement should be less than m + n. Hence (c) is correct option.

    Correct Option: C

    For every Pi Si is maximum resource requirement where Si > 0. To allot resources to all processes without any deadlock situation is

    i.e. sum of all maximum resource requirement should be less than m + n. Hence (c) is correct option.



Direction: Barrier is a synchronization construct where a set of processes synchronizes gobally, i.e., each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be 3 and S be a binary semaphore with the usual P and V function. Consider the following C implementation of a barrier with line numbers shown on left:
void barrier (void) {
1: P(S);
2: process_arrived ++;
3: V(S);
4: while (process_arrived! = 3);
5: P(S);
6: process_left++;
7: if (process_left = = 3);{
8: process_arrived = 0;
9: process_left = 0;
10:}
11: V(S); }
The variables process-arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally.

  1. Which one of the following rectifies the problem in the implementation?









  1. View Hint View Answer Discuss in Forum

    To rectify the barrier function at the beginning of the functions the first process which inters the function waits until process arrived becomes zero before executing P(s). This removes any deadlock situation. Hence (b) is correct option.

    Correct Option: B

    To rectify the barrier function at the beginning of the functions the first process which inters the function waits until process arrived becomes zero before executing P(s). This removes any deadlock situation. Hence (b) is correct option.


  1. The above implementation of barrier is incorrect. Which one of the following is true?









  1. View Hint View Answer Discuss in Forum

    This barrier implementation is to keep track of arrival & completion of processes in system, by incrementing no. of process arrived & left. This implementation may lead to deadlock if two barrier function's invocations are used is immediate sessions. SinceV(s) in first invocation at line 3 removes 1-3 from critical section bring 5-11 in critical section at line 7. Hence (b) is correct option.

    Correct Option: B

    This barrier implementation is to keep track of arrival & completion of processes in system, by incrementing no. of process arrived & left. This implementation may lead to deadlock if two barrier function's invocations are used is immediate sessions. SinceV(s) in first invocation at line 3 removes 1-3 from critical section bring 5-11 in critical section at line 7. Hence (b) is correct option.



  1. Consider the following snapshot of a system running n processes. Process/is holding Xi instances of a resource R, I ≤ i ≤ n. Currently, all instances of R are occupied. Further, for all i process i has placed a request for an additional yi instances while holding the xi instances it already has. There are exactly two processes p and q such that yp = yq = 0. Which one of the following can serve as a necessary condition to guarantee that the system is not approaching a deadlock?









  1. View Hint View Answer Discuss in Forum

    Here option (b) is that min (xp ,xq) < maxk? p,q yk Means the min no. of resources allocated should be less than the maximum number of resources required by any process other than p & q. So, It prevent from deadlock.
    Hence (b) is correct option.

    Correct Option: B

    Here option (b) is that min (xp ,xq) < maxk? p,q yk Means the min no. of resources allocated should be less than the maximum number of resources required by any process other than p & q. So, It prevent from deadlock.
    Hence (b) is correct option.