The semaphore variables full, empty and mutex are initialized to 0, n and 1,…

GATE · 2004 · IT

The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process P2 repeatedly removes one item at a time from the same buffer using the programs given below. In the programs, K, L, M and N are unspecified statements.

P1

while (1) {
    K; P(mutex); Add an item to the buffer; V(mutex);     L; } P2 while (1) {    M; P(mutex); Remove an item from the buffer; V(mutex);     N; } The statements K, L, M and N are respectively

  1. A.

    P(full), V(empty), P(full), V(empty)

  2. B.

    P(full), V(empty), P(empty), V(full)

  3. C.

    P(empty), V(full), P(empty), V(full)

  4. D.

    P(empty), V(full), P(full), V(empty)

Attempted by 282 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…