Date: Wed, 18 Jan 2006 10:38:34 +0100 From: rookie <asmrookie@gmail.com> To: deischen@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: Re: How priority propagation works on read/write lock? Message-ID: <3bbf2fe10601180138m3a5ab67cx@mail.gmail.com> In-Reply-To: <Pine.GSO.4.43.0601171417180.13239-100000@sea.ntplx.net> References: <3bbf2fe10601171111x7432a2aaj@mail.gmail.com> <Pine.GSO.4.43.0601171417180.13239-100000@sea.ntplx.net>
next in thread | previous in thread | raw e-mail | index | archive | help
>> This approach fails beacause you need to propagate priority for any blocking >> thread for any owners (if needed). > I'm not sure I follow -- got a simple example? > A writer won't be able to get the write lock until _all_ of the > current read lock owners have released the lock. It doesn't > matter which of the readers you propagate to, eventually all > of them will have their priority propagated. > > On a single CPU system, there is no advantage to propagating > priority to all of the current readers because only one can > run at a time. On an SMP system, the disadvantage is that you > lose the ability for multiple read lock owners to run at the > same time. Let's say: threads A, B, C own a read lock (RW1). After a while: - A blocks on a write lock (D thread owns) - B blocks on a read lock (owned by other threads, we say E1, E2, E3) - C blocks on a mutex (owned by F) Now if a thread G blocks on RW1 and its priority is higher than A,B,C (whic= h might have the same priority) priority propagation is needed to hit D, { E1= , E2, E3 } and F. If you just do priority propagation for one of them the other would not be updated. turnstiles don't hurts beacause some intrusive lists are defined involving turnstiles and threads so a sort of "chain" like that: turnstile->thread->turnstile->thread... is provided. In the case of multple thread we could have a situation like: thread1 thread1 turnstile->thread2->turnstile--------------->thread2 thread3->turnstile->thread thread3 And so on. I did a recursive algorithm for a new primitive (rwblock) which correctly implements priority propagation for multiple owners mechanism but there are 2 problems: 1) this algorithm is recursive and it's enough hard to change 2) With a new primitive some work of integration between existing (turnstiles) might be provided. Currently I'm working on both these problematics and I hope to do something better next times. Cheers, Attilio -- Peace can only be achieved by understanding - A. Einstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3bbf2fe10601180138m3a5ab67cx>