Question: In the following code, three processes are synchronized using two semaphores L and R and produce output using the routine putc. (a) How many D's

In the following code, three processes are synchronized using two semaphores L and R and produce output using the routine putc.

semaphore L. value = 3, R.value = 0; /* initialization */ /*

(a) How many D's are printed when these processes run?

(b) Is CABABDDCABCABD a possible output sequence when these processes run?

(c) Is CABACDBCABDD a possible output sequence when these processes run?

semaphore L. value = 3, R.value = 0; /* initialization */ /* Process 1 */ /* Process 2 */ L1: L2: wait (L); putc ('C'); signal (R); goto L1; wait (R); putc ('A'); putc ('B'); signal (R); goto L2; /* Process 3 */ L3: wait (R); putc ('D'); goto L3;

Step by Step Solution

3.31 Rating (142 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To answer the questions we need to understand how these processes are synchronized using the semaphores L and R and how they produce their outputs Sem... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Biology Questions!