In this synchronization problem, imagine a database with three types of accesses: search (read the database), insert (insert a record to the database), and delete (remove a record to the database). There are several concurrency rules that must be followed:
- Search operations can access the database concurrently with other search operations.
- Search operations can access the database concurrently with an insert operation.
- Only one insert operation can access the database at a time (it is an error if two insert operations are concurrently accessing the database). As noted in the previous rule, the insert operation can run concurrently with any number of search operations.
- Delete operations must have exclusive access to the database (no other search, insert, or delete operations can run concurrently).
The implementation is identical to that of the readers-writers problem except for the following differences:
- The threads are divided into three types based on the access: search, insert, and delete. An enumerated type is used to distinguish between the types.
- The checker is altered to reflect the mutual exclusion rules.