Question: 4. The readers-writers problem is a classical one in computer science: we have a resource (e.g., a database) that can be accessed by readers, who
4. The readers-writers problem is a classical one in computer science: we have a resource (e.g., a database) that can be accessed by readers, who do not modify the resource, and writers, who can modify the resource. When a writer is modifying the resource, no-one else (reader or writer) can access it at the same time: another writer could corrupt the resource, and another reader could read a partially modified (thus possibly inconsistent) value. Consider the three variants of the existing problem. a. Give readers priority: when there is at least one reader currently accessing the resource, allow new readers to access it as well. This can cause starvation if there are writers waiting to modify the resource and new readers arrive all the time, as the writers will never be granted access if there is at least one active reader. b. Give writers priority: here, readers may starve. c. Give neither priority, the third readers-writers problem: all readers and writers will be granted access to the resource in their order of arrival. If a writer arrives while readers are accessing the resource, it will wait until those readers free the resource, and then modify it. New readers arriving in the meantime will have to wait. i. Write an algorithm/pseudocode as a proof of your work. ii. Using POSIX threads, mutex locks, and semaphores write a program for the third readers-writers problem including clocks keeping in the mind that you must adhere to happens-before relationship according to the Lamports Vector Logical Clock. iii. Provide the test suite and the results of the Alpha Testing. iv. Provide the test suite and the results of the Beta Testing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
