CS FundamentalsHardGATE CS (PYQ pattern)
Locks are ordered L1 < L2 < L3 < L4 and every thread must acquire locks in increasing order. A thread acquires locks in the following sequence and releases a lock only where stated: lock L1, lock L3, release L3, lock L2, lock L4, lock L3. At which acquisition does it first violate the ordering rule?
- A. The final lock L3 (L4 is held and L3 < L4)
- B. lock L2 (L3 was acquired before it)
- C. lock L4 (L2 is held)
- D. It never violates the rule
Correct answer: A. The final lock L3 (L4 is held and L3 < L4)
After 'release L3' the thread holds only L1, so locking L2 is fine, and L4 is fine (above L2). The last acquisition requests L3 while holding L4, which breaks the increasing-order rule.
More Operating Systems questions
- Memory (in KB, from address 0): OS 100, process A 150, hole 60, B 200, hole 90, C 120, hole 80, D 100, hole 100. Compaction slides every…
- A 100 MB process is swapped out and later swapped back in on a disk that transfers 50 MB/s with an 8 ms latency per transfer. Swap-out…
- Disk requests arrive as a Poisson stream of 100 per second; service times are exponential (M/M/1 per disk). Option X buys one disk twice…
- Round Robin uses a 20 ms quantum and every context switch costs 2 ms; all n processes are CPU-bound and always use the full quantum. From…
- A ticket lock has nextticket = 10 and nowserving = 10 (free). Events in order: T1 acquires, T2 acquires, T3 acquires, T1 releases, T4…
- Which of the following statements about read-copy-update (RCU) are correct? I. Readers traverse the data structure without taking locks…