Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1: Synchronization (30 pts] Consider a shared database with two classes of users: Readers - never modify database. Writers read and modify database. As
Question 1: Synchronization (30 pts] Consider a shared database with two classes of users: Readers - never modify database. Writers read and modify database. As discussed in lecture, concurrency functionality can be implemented with the following scheme Scheme A: Shared Data: Semaphore rw_mutex initialized to 1 Semaphore mutex initialized to 1 Integer read_count initialized to o Writer Process: do wait (rw_mutex); i* writing is performed / signal(rw_mutex); } while (true); Reader Process: do wait (mutex); read_count++; if (read_count == 1) wait (rw_mutex); signal (mutex); 7 reading is performed / wait (mutex); read_count--; if (read_count == 0) signal (rw_mutex); signal (mutex); } while (true); Now consider a new class of user called Scrubbers. Scrubbers perform an action which is to scrub items in the database. We can have an arbitrary number of scrubbers scrubbing the same item at once. An item should not be read or written while it is being scrubbed. An item should not scrubbed while it is being written or read. Write down a scheme in a format like scheme A above which implements the concurrency functionality of Readers, Writers, and Scrubbers. [30 pts] Question 1: Synchronization (30 pts] Consider a shared database with two classes of users: Readers - never modify database. Writers read and modify database. As discussed in lecture, concurrency functionality can be implemented with the following scheme Scheme A: Shared Data: Semaphore rw_mutex initialized to 1 Semaphore mutex initialized to 1 Integer read_count initialized to o Writer Process: do wait (rw_mutex); i* writing is performed / signal(rw_mutex); } while (true); Reader Process: do wait (mutex); read_count++; if (read_count == 1) wait (rw_mutex); signal (mutex); 7 reading is performed / wait (mutex); read_count--; if (read_count == 0) signal (rw_mutex); signal (mutex); } while (true); Now consider a new class of user called Scrubbers. Scrubbers perform an action which is to scrub items in the database. We can have an arbitrary number of scrubbers scrubbing the same item at once. An item should not be read or written while it is being scrubbed. An item should not scrubbed while it is being written or read. Write down a scheme in a format like scheme A above which implements the concurrency functionality of Readers, Writers, and Scrubbers. [30 pts]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started