1

So this is a general question about the use of monitors in the Reader/Writers problem.

I know the monitor procedures for the Readers/Writers problem are used for mutual exclusion to a critical section, but my professor claims the critical section is outside the monitor as opposed to being inside the monitor for the Reader/Writers problem? Why?

I supposed the critical section is outside the monitor since the monitor is supposed to encapsulate shared data structures, procedures operating on those data structures, and synchronization between concurrent procedure invocations. Thus, a monitor is used to make sure that a writer does not illegitimately access its data through its procedures... But when I went searching, I found out that many programmers implemented the monitor with the critical section inside as opposed to outside.

  • You need a clearer (and a bit more formal) definition of what "monitor" refers to. Not the concept itself, but whether "monitor" refers to the code that enforces exclusivity of some other code, or the code that is being protected (enjoying the guarantee of exclusivity) thanks to the monitor. Thus, your question is as much a word question as a computer science concept question. – rwong Nov 12 '14 at 5:36
  • By "the code that enforces ..." (the code that implements monitor), I refer to the code responsible for: registering with the condition variable; blocking the thread (either by spinning or putting the thread to sleep or by switching to another unblocked task or somehow invoking the OS to do the same), and reviving (continuing) the execution once the mutex is grabbed. – rwong Nov 12 '14 at 5:39
  • I am referring to the code that implements monitor - as with your last comment @rwong – B. Duarte Nov 12 '14 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.