Operating System MCAO (Computer Science). The readers-writers dilemma is related to an item that is shared by numerous processes, such as a file. Some of these processes are readers, meaning they just want to read data from the object, while others are writers, meaning they want to write into the object. To ensure consistency, every writer must acquire a lock on the object before modifying it. This prevents multiple writers from executing simultaneously. There are two types of locks: shared and exclusive. A shared lock can be acquired by any number of processes, whereas an exclusive lock can be obtained by only one process at a time. Shared locks are necessary because not all parts of a program should be writing to the same resource at once. For example, if a database were used as an application resource, some programs might need only read access to the data, while other programs or modules could benefit from being able to update the data too. Using shared locks ensures that multiple programs do not attempt to modify the resource simultaneously, thereby avoiding data corruption. Exclusive locks are needed when making a change is more important than maintaining consistency. For example, if a process was in the middle of saving data to a file when another process tried to make an identical save request, the second process would have to wait for the first process to finish before doing so.