Operating systems miscellaneous


Operating systems miscellaneous

  1. A system shares 9 tape drives. The current allocation and maximum requirement of tape drives for three processes are shown below:
    Process Current Allocation MaximumRequirement
    P1 3 7
    P2 1 6
    P3 3 5

    Which of the following best describes current state of the system?









  1. View Hint View Answer Discuss in Forum

    As given table is:

    There are total 9 tape drives.
    So according to the above table we can see that, it have currently allocated 7 tape drive, so currently available tape drive
    ⇒ 9 – 7 = 2.
    So, P3 can use it and after using, it will release 3 then new resources are available = 5, then P1 can use it and it will release 3, so new available resources = 8, and lastly P2 can use it so all the process are in 'SAFE STATE' and there will be No 'DEADLOCK'. Then we can get the following 2 safe sequence
    (1) 3, P2, P1 > (2) 3, P1, P2 >.
    So, system is in safe state from (P3 → P1 → P2) and no deadlocked. Hence, option (b) is correct.

    Correct Option: B

    As given table is:

    There are total 9 tape drives.
    So according to the above table we can see that, it have currently allocated 7 tape drive, so currently available tape drive
    ⇒ 9 – 7 = 2.
    So, P3 can use it and after using, it will release 3 then new resources are available = 5, then P1 can use it and it will release 3, so new available resources = 8, and lastly P2 can use it so all the process are in 'SAFE STATE' and there will be No 'DEADLOCK'. Then we can get the following 2 safe sequence
    (1) 3, P2, P1 > (2) 3, P1, P2 >.
    So, system is in safe state from (P3 → P1 → P2) and no deadlocked. Hence, option (b) is correct.


  1. Consider the following policies for preventing deadlock in a system with mutually exclusive resources.
    i. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released.
    ii. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
    iii. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
    iv. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources
    Which of the above policies can be used for preventing deadlock?









  1. View Hint View Answer Discuss in Forum

    For deadlock prevention we need to dissatisfy any of the necessary condition for deadlock
    1. For hold and wait if we dissatisfy it can be hold or wait for hold …before process start os assign all resources. While executing if process making new resource request it has to release all its assign resources that is waiting for release resources.
    2. If we dissatisfy circular wait condition suppose there r five resources uniquely numbered r1 to r5 and there five processes p1 to p5 suppose p2 hold r1, and requesting for r2, and r2 hold by p3 and wait for r3, r3 hold by p4 wait for r4 which is hold by p5 and wait for r5 which is held by p1 (this is happening in circular manner)(condition to come out from circular wait is a process can hold the resource and request for new resource only when holding resource id is lesser then requesting resource id) in above p1 is violating condition.
    3. If we dissatisfy preemption if a process hold some resources requesting for new resources and that requesting resources are busy with some other process requesting process voluntarily release its held resources.
    According to 1 and 3 above statements, first statement (i) is correct.
    According to above second statement, second statement (ii) is correct.
    According to above second statement if we implement the logic in reverse order then the third statement (iii) is also correct.
    According to second statement condition statement (iv) is also correct.

    Correct Option: D

    For deadlock prevention we need to dissatisfy any of the necessary condition for deadlock
    1. For hold and wait if we dissatisfy it can be hold or wait for hold …before process start os assign all resources. While executing if process making new resource request it has to release all its assign resources that is waiting for release resources.
    2. If we dissatisfy circular wait condition suppose there r five resources uniquely numbered r1 to r5 and there five processes p1 to p5 suppose p2 hold r1, and requesting for r2, and r2 hold by p3 and wait for r3, r3 hold by p4 wait for r4 which is hold by p5 and wait for r5 which is held by p1 (this is happening in circular manner)(condition to come out from circular wait is a process can hold the resource and request for new resource only when holding resource id is lesser then requesting resource id) in above p1 is violating condition.
    3. If we dissatisfy preemption if a process hold some resources requesting for new resources and that requesting resources are busy with some other process requesting process voluntarily release its held resources.
    According to 1 and 3 above statements, first statement (i) is correct.
    According to above second statement, second statement (ii) is correct.
    According to above second statement if we implement the logic in reverse order then the third statement (iii) is also correct.
    According to second statement condition statement (iv) is also correct.



  1. A system has 6 identical resources and N processes competing for them. Each process can request atmost 2 resources. Which one of the following values of N could lead to a deadlock?











  1. View Hint View Answer Discuss in Forum

    It might be "WRONG" question.

    N = 2 ⇒ P1P2     No. of resources = 6
    2 2
    1 1

    Each process can request atmost 2
    N = 3 ⇒ P1 P2 P3
    222

    N = 4 ⇒ P1 P2 P3 P4
    1111
    11

    Therefore, no option leads to dead lock.

    Correct Option: E

    It might be "WRONG" question.

    N = 2 ⇒ P1P2     No. of resources = 6
    2 2
    1 1

    Each process can request atmost 2
    N = 3 ⇒ P1 P2 P3
    222

    N = 4 ⇒ P1 P2 P3 P4
    1111
    11

    Therefore, no option leads to dead lock.


  1. An operating system uses the Banker’s algorithm for deadlock avoidance when managing the allocation of three resource types X, Y, and Z to three processes P0, P1, and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution.

    There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in a safe state. Consider the following independent requests for additional resources in the current state:
    REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z
    REQ2: P1 requests 2 units of X, 0 units of Y and 0 units of Z Which one of the following is TRUE ?









  1. View Hint View Answer Discuss in Forum

    Only REQ2 can be permitted.

    Correct Option: B

    Only REQ2 can be permitted.



  1. Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.
    repeat flag [i] = true;
        turn = j;
    while (P) do no-op;
    Enter critical section, perform actions, then exit critical section
    Flag [i] = false;
    Perform other non-critical section actions. Until false;
    For the program to guarantee mutual exclusion, the predicate P in the while loop should be









  1. View Hint View Answer Discuss in Forum

    A mutual exclusion look is called mutex. In this two or more processes executes simultaneously and wait for the execution of another process. The process is called deadlock when two or more process simultaneously trying to enter a critical section, look each other out.
    Let look at the simple algorithm for achieving the mutual exclusion between two processes with PID
    equal to 0 or 1
    int turn;
    int interested [2];
    void Get_Mutex (int pid)
    {
    int other;
    other = 1-pid;
    while (turn = = pid && interested [other])
    {
    }
    }
    release_mutex (int pid)
    {
    interested [pid] = false;
    }
    While loop if true predicate then the program enters into critical region. This program enters into critical region of flag [i]=true act as semaphore, & true =j, the requirement of resource is by some other process.
    Hence (b) is correct option.

    Correct Option: B

    A mutual exclusion look is called mutex. In this two or more processes executes simultaneously and wait for the execution of another process. The process is called deadlock when two or more process simultaneously trying to enter a critical section, look each other out.
    Let look at the simple algorithm for achieving the mutual exclusion between two processes with PID
    equal to 0 or 1
    int turn;
    int interested [2];
    void Get_Mutex (int pid)
    {
    int other;
    other = 1-pid;
    while (turn = = pid && interested [other])
    {
    }
    }
    release_mutex (int pid)
    {
    interested [pid] = false;
    }
    While loop if true predicate then the program enters into critical region. This program enters into critical region of flag [i]=true act as semaphore, & true =j, the requirement of resource is by some other process.
    Hence (b) is correct option.