Question: Operating Systems: Consider (again) the Readers-Writers solution using semaphores given in the lecture notes (09-Semaphores, Slide 11). No readers and no writers are currently in

Operating Systems:

Consider (again) the Readers-Writers solution using semaphores given in the lecture notes (09-Semaphores, Slide 11). No readers and no writers are currently in the database. For the following sequence of events, describes what happens. That is, state where each process will block (if it blocks). Describe any processes released as a result of an event and where they each then go.

a.) Writer 1 arrives

b.) Reader 1 arrives

c.) Reader 2 arrives

d.) Writer 2 arrives

e.) Reader 3 arrives

f.) Writer 1 leaves

g.) Reader 4 arrives

h.) Current occupant of the database leaves. If more than one process was in the database, assume all of them leave at this point. What happens now?

i.) Writer 3 arrives and Reader 5 arrives in that order. Then what happens? That is, describe the sequence of events until all Readers and Writers have finished and have left. (No new Readers or Writers arrive.)

Operating Systems: Consider (again) the Readers-Writers solution using semaphores given in the

Reador Processos Writor Procossos P Mutox )i if ( (Activewriters == 0) && P Mutox )i (WaitingWriters 0))t (ActiveReaders == 0) && (WaitingWriters - 0)) t ActiveReaders++ ActiveWriters++ else WaitingReaders++ else V( Mutex ); WaitingWriters++ V( Mutex )i P( OKToRead); P( Mutex ), ActivoReaders-- if ( (ActiveReaders == 0) && P( Mutex )i ActiveWriters-- if ( WaitingWritors >0 (WaitingWritors > 0)f /*wako up a writor * V( OKTowrito /*wako up a writor*/ ActivoWritors++ WaitingWriters-- ActiveWriters++ WaitingWriters--i olse /*wake up all the waiting readers while WaitingReaders > 0 V( OKToReadi ActiveReaders++ WaitingReaders-- Mutex ); CSc 452 -Principles of Operating Systems 09 - Synchronization via Semaphores

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!