CS FundamentalsVery hardGATE CS · Advanced
A semaphore s is initialised to 0. Three threads run concurrently, and print(X) prints the single letter X atomically. Thread 1: print(A); V(s); print(B). Thread 2: P(s); print(C); print(D). Thread 3: print(E); print(F). How many different complete output strings are possible?
- A. 41
- B. 45
- C. 90
- D. 51
Correct answer: B. 45
The outputs are the interleavings of A-B, C-D, E-F in which A comes before C (P(s) cannot pass before V(s), and A precedes V). Of the 90 interleavings of three 2-letter chains, those with A before C are counted: 45.
More Operating Systems questions
- Two threads share an integer x initialised to 0. Thread 1 executes the loop body x = x + 1 three times; Thread 2 executes it twice. Each…
- Four periodic tasks (computation time C, period T = relative deadline), all released at t = 0, are scheduled by preemptive rate-monotonic…
- A disk spins at 7200 rpm with 500 sectors per track and an average seek time of 5 ms. The controller adds 0.2 ms of overhead. What is the…
- A stride scheduler gives processes A, B and C 100, 50 and 250 tickets respectively, with stride = 10000 / tickets. Every process starts…
- A process uses 100 MiB of memory. A page-table entry is 8 bytes, and on average half of the last page is wasted. Among page sizes that are…
- The aging algorithm keeps an 8-bit counter per page for pages 0-3. At the end of every clock tick each counter is shifted right by one bit…