GATEverse
← GATE CSE 2023

Q28

MCQ2 marks, −0.67

Consider the two functions incr\textsf{incr} and decr\textsf{decr} shown below. incr(){ decr(){ wait(s); wait(s); X = X+1; X = X-1; signal(s); signal(s); } } There are 55 threads each invoking incr\textsf{incr} once, and 33 threads each invoking decr\textsf{decr} once, on the same shared variable X\mathrm{X}. The initial value of X\mathrm{X} is 10.10. Suppose there are two implementations of the semaphore s,\text{s}, as follows: I-1:  s\textbf{I-1:} \;\mathrm{s} is a binary semaphore initialized to 1.1. I-2:  s\textbf{I-2:}\; \mathrm{s} is a counting semaphore initialized to 2.2. Let V1, V2\text{V1, V2} be the values of X\text{X} at the end of execution of all the threads with implementations I-1, I-2,\textbf{I-1, I-2}, respectively. Which one of the following choices corresponds to the minimum possible values of V1, V2,\text{V1, V2}, respectively?

Sign in to save attempts.

Loading…