Question: 6 . 1 8 Consider a system consisting of processes P 1 , P 2 , dots, P n , each of which has a
Consider a system consisting of processes dots, each of which has
a unique priority number. Write a monitor that allocates three identical
line printers to these processes, using the priority numbers for deciding
the order of allocation.
Answer: Here is the pseudocode:
monitor printers
int numavail ;
int waitingprocesses MAXPROCS ;
int numwaiting;
condition ;
void requestprinter int procnumber
if numavail
numavail;
return;
waitingprocesses numwaiting procnumber;
numwaiting;
sort waitingprocesses;
while numavail &&
waitingprocesses procnumber
cwait ;
waitingprocesses
waitingprocesses numwaiting ;
numwaiting ;
sort waitingprocesses ;
numavail;
void releaseprinter
numavail;
cbroadcast ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
