Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 . 1 8 Consider a system consisting of processes P 1 , P 2 , dots, P n , each of which has a

6.18 Consider a system consisting of processes P1,P2,dots,Pn, 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 num_avail =3;
int waiting_processes [MAX_PROCS] ;
int num_waiting;
condition c;
void request_printer (int proc_number){
if (num_avail >0){
num_avail--;
return;
}
waiting_processes [num_waiting]= proc_number;
num_waiting++;
sort (waiting_processes);
while (num_avail ==0 &&
waiting_processes [0]!= proc_number)
c.wait () ;
waiting_processes [0]=
waiting_processes [num_waiting-1] ;
num_waiting-- ;
sort (waiting_processes) ;
num_avail--;
}
void release_printer(){
num_avail++;
c.broadcast () ;
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

what is a peer Group? Importance?

Answered: 1 week ago