To overcome difficulties in Readers-Writers problem, which of the following…

2018

To overcome difficulties in Readers-Writers problem, which of the following statement/s is/are true?

(i) Writers are given exclusive access to shared objects.

(ii) Readers are given exclusive access to shared objects.

(iii) Both Readers and Writers are given exclusive access to shared objects.

Choose the correct answer from the code given below :

𝐶𝑜𝑑𝑒:

  1. A.

    (i) only

  2. B.

    (ii) only

  3. C.

    (iii) only

  4. D.

    Both (ii) and (iii)

Attempted by 336 students.

Show answer & explanation

Correct answer: A

Answer: (i) Writers are given exclusive access to shared objects.

Explanation: Writers must have exclusive access so that a writer does not conflict with other writers or with readers (prevents write-write and read-write races). Readers, on the other hand, may access the shared object concurrently as long as no writer is active; this improves concurrency and throughput.

  • Writers need exclusivity: when a writer is active, no other reader or writer should access the object.

  • Readers can share access: multiple readers may read simultaneously if no writer is active.

  • Why the other statements are false: claiming that readers are exclusive would block concurrent readers unnecessarily; claiming both readers and writers are exclusive contradicts the usual readers-writers model that allows concurrent readers.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor