GATEverse
← GATE IT 2006

Q57

MCQ2 marks, −0.5

The wait and signal operations of a monitor are implemented using semaphores as follows. In the following, xx is a condition variable, mutex is a semaphore initialized to 11, xx_sem is a semaphore initialized to 00, xx_count is the number of processes waiting on semaphore xx_sem, initially 00, next is a semaphore initialized to 00, next_count is the number of processes waiting on semaphore next, initially 00. 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 xx.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 xx.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 E1E1 and E2E2 are, respectively,

Sign in to save attempts.

Loading…