lkml.org 
[lkml]   [1999]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch] shm bug introduced with pagecache in 2.3.11
In article <Pine.LNX.4.10.9911191120530.1216-100000@penguin.transmeta.com> you wrote:


> 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/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:1.994 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site