7.4.1 Reader/Writer Locking

If synchronization overhead is negligible (for example, if the program uses coarse-grained parallelism), and if only a small fraction of the critical sections modify data, then allowing multiple readers to proceed in parallel can greatly increase scalability. Writers exclude both readers and each other. Figure [*] shows how the hash search might be implemented using reader-writer locking.

Figure: Reader-Writer-Locking Hash Table Search
\begin{figure}{ \scriptsize
\begin{verbatim}1 rwlock_t hash_lock;
2
3 struc...
...}
29 read_unlock(&hash_lock);
30 return 0;
31 }\end{verbatim}
}\end{figure}

Reader/writer locking is a simple instance of asymmetric locking. Snaman [ST87] describes a more ornate six-mode asymmetric locking design used in several clustered systems. Locking in general and reader-writer locking in particular is described extensively in Chapter [*].



Paul E. McKenney 2011-12-16