Ask Question
7 December, 05:25

Consider a system consisting of processes P1, P2, ..., Pn, each of which has a unique priority number. Write a monitor that allocates three identical printers to these processes, using the priority numbers for deciding the order of allocation.

+4
Answers (1)
  1. 7 December, 08:58
    0
    See explaination

    Explanation:

    The code

    type printer = monitor

    var P: array[0 ...2] of boolean;

    X: condition;

    procedure acquire (id: integer, printer-id: integer);

    begin

    if P[0] and P[1] and P[2] then X. wait (id)

    if not P[0] then printer-id : = 0;

    else if not P[1] then printer-id : = 1;

    else printer-id : = 2;

    P[printer-id]:=true;

    end;

    procedure release (printer-id: integer)

    begin

    P[printer-id]:=false;

    X. signal;

    end;

    begin

    P[0] : = P[1] : = P[2] : = false;

    end;

    Note:

    Monitors are implemented by using queues to keep track of the processes attempting to become active int he monitor. To be active, a monitor must obtain a lock to allow it to execute the monitor code. Processes that are blocked are put in a queue of processes waiting for an unblocking event to occur.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider a system consisting of processes P1, P2, ..., Pn, each of which has a unique priority number. Write a monitor that allocates three ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers