Readers-writer lock

From Wikipedia, the free encyclopedia

In computer science, a readers-writer lock (also known by the name multi-reader lock, or by typographical variants such as readers/writers lock) is a synchronization primitive that solves one of the readers-writers problems. A readers-writer lock is like a mutex, in that it controls access to some shared memory area, but it allows multiple threads to read from the shared area concurrently. Any thread that needs to write to the shared memory, of course, needs to acquire an exclusive lock.

Readers-writer locks are usually constructed on top of mutexes and condition variables, or on top of semaphores. They are rarely implemented from scratch.