GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2020

GATE 2020 · CS · MCQ · 2 marks · Operating System › Process Synchronization

GATE 2020 Computer Science and Information Technology question: Each of a set of n processes executes the following code using two semaphores a and b…

Each of a set of processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.

CODE SECTION P

wait(a); count=count+1;
if (count==n) signal(b);
signal(a); wait(b); signal(b);

CODE SECTION Q

What does the code achieve?

  1. (A)

    It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.

  2. (B)

    It ensures that at most two processes are in CODE SECTION Q at any time.

  3. (C)

    It ensures that all processes execute CODE SECTION P mutually exclusively.

  4. (D)

    It ensures that at most processes are in CODE SECTION P at any time.

Show answer

Official answer: A

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion