Operating System Design/Processes/Locks

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Locks are methods of synchronization used to prevent multiple threads from accessing a resource at the same time. Usually, they are advisory locks, meaning that each thread must cooperate in gaining and releasing locks. More difficult to implement and less common, mandatory locks actually prevent any other thread from accessing a resource, and issue an exception if this occurs.

One common lock mechanism is the semaphore.