A monitor uses wait and signal methods to respectively block

A \'monitor\' uses wait() and signal() methods to respectively block and wake up a process on a condition variable. Suppose we do not have any implementation of \'mutex\' semaphore. Suggest a monitor-based implementation of a \'mutex\' semaphore.

Solution

As Moniters guarantees ME. we see in terms of parallelism.

Lets take an example:

wothdrawl(amount) (balance=balnce-account) -> Threads wiating to get into monitor

rerturn balnce and exit

When first thread exits, another can enter. our conditional variables sre signal() and wait().

So, we can use Moniter Queues

Moniter bounded_buffer{ <---- waiting to enter

condition not_full <---- waiting on condinal variables

... other variables

condition not_empty

void put_resource(){
.. wait(not_full).. <--- Executing inside monitor

....signal(not_empty)...

}

Resource get_resource(){

----

}

}

And also hoare monitor uses if

Mesa monitor uses while, the latter is eaier and efficient than the former, as the former has less chance.

 A \'monitor\' uses wait() and signal() methods to respectively block and wake up a process on a condition variable. Suppose we do not have any implementation o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site