Appendices > Portable Thread Library > Readers/Writer Lock
 
Readers/Writer Lock
As described in Mutexes, mutexes are the simplest way to protect access to a resource. In some cases, however, you might want to protect a resource with a readers/writer lock. This will be the case you expect many threads to access the resource for read access, while, occasionally, another thread may access the thread for write access in order to modify the resource.
With a readers/writer lock, many readers can access the resource, but only one writer can have exclusive access to the resource at any one time. The algorithm for requiring access to the resource is that readers will be allowed access until there are one or more writers waiting. Once there is a writer waiting, all new readers are blocked and all the threads will wait until the remaining readers have finished and all waiting writers have run in turn.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.