Книга: Programming with POSIX® Threads
10.2.2 Read/write locks
10.2.2 Read/write locks
A read/write lock (also sometimes known as "reader/writer lock") allows one thread to exclusively lock some shared data to write or modify that data, but also allows multiple threads to simultaneously lock the data for read access. UNIX98 specifies "read/write locks" very similar to POSIX.1j reader/writer locks. Although X/Open intends that the two specifications will be functionally identical, the names are different to avoid conflict should the POSIX standard change before approval.
If your code relies on a data structure that is frequently referenced, but only occasionally updated, you should consider using a read/write lock rather than a mutex to access that data. Most threads will be able to read the data without waiting; they'll need to block only when some thread is in the process of modifying the data. (Similarly, a thread that desires to write the data will be blocked if any threads are reading the data.)
See Section 7.1.2 for details of read/write lock behavior and for an example showing how to implement a read/write lock using standard Pthreads synchronization. (Note that the behavior of this example is not precisely the same as that proposed by POSIX.1j.)
*The POSIX working group is considering the possibility of adapting the XSH5 read/write lock definition and abandoning the original POSIX.1j names, but the decision hasn't yet been made.
- Класс StreamReader
- How to read
- 6.6.5 SIGEV_THREAD
- При запуске программы появляется сообщение Инструкция по адресу 0х77ddb1d1 обратилась к памяти по адресу 0x0080002c. Пам...
- В Adobe Acrobat Reader русский текст на экране читается нормально, а при печати получается текст из набора символов. Как...
- 4 A few ways to use threads
- Reading Documentation
- RSS Readers
- The Pan News Client Newsreader
- Функция pthread_rwlock_trywrlock
- Reading Manual Pages with man
- Mounting a Partition as Read-Only on a Running System