Q57
MCQ2 marks, −0.5The wait and signal operations of a monitor are implemented using semaphores as follows. In the following, is a condition variable, mutex is a semaphore initialized to , _sem is a semaphore initialized to , _count is the number of processes waiting on semaphore _sem, initially , next is a semaphore initialized to , next_count is the number of processes waiting on semaphore next, initially . The body of each procedure that is visible outside the monitor is replaced with the following: P(mutex); ... body of procedure ... if (next_count > 0) V(next); else V(mutex); Each occurrence of .wait is replaced with the following: x_count = x_count + 1; if (next_count > 0) V(next); else V(mutex); ------------------------------------------------------------ E1; x_count = x_count - 1; Each occurrence of .signal is replaced with the following: if (x_count > 0) { next_count = next_count + 1; ------------------- E2; P(next); next_count = next_count - 1; } For correct implementation of the monitor, statements and are, respectively,
Loading…