569 views

1 Answer

Best answer
1 votes
1 votes

Assuming 6th last line is r – – ;

  1. Going for option A:

There can be more than 100 readers reading, this is breaking the rule as question mentioned maximum 100 readers.

  1. Going for option C&D:

Reader 1: Comes make m = 0 then make s = 99 and m = 1 → Reading

Reader 2: Comes make m = 0 then make s = 98 and m = 1 → Reading

Reader 100: Comes make m = 0 then make s = 0 and m = 1 → Reading

Reader 101: Comes make m = 0 then waiting for s.

Now Reader 1 finish reading… While going out he needs to down(m) but can’t do since it is holded by Reader 101. We got into deadlock.

 

Hence I think B should be correct option.

selected by

Related questions

0 votes
0 votes
0 answers
3