> Well, the more I look at a read-write semaphore, the more I like it: it
> Is anybody willing to take a stab at creating a read-write semaphore?
The book "UNIX Systems for Modern Architectures" by Curt Schimmel discusses
read-write semaphores on page 234, he also has a prototype implementation,
based on "normal" semaphores.
The book suggests a per semaphore lock for internal variables.
The struct mr_lock looks like this (pseudo C)
struct mr_lock {
semap_t m_lock; /* protects the structure mr_lock */
int m_rdcnt; /* # of active readers */
int m_wrcnt; /* # of active writers, 0 or 1 */
int m_rdwcnt; /* # of waiting reader */
int m_wrcnt; /* # of waiting writers */
waitqueue m_rdwait; /* waitqueue of waiting readers */
waitqueue m_wrwait; /* waitqueue of waiting writers */
}
Do you think an implementation based on this (and the other examples from
the book) is acceptable? Since the implementation uses already available
primitives, no assembly or other architecture-specific stuff is required.
Greetings,
Arjan van de Ven
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/