Re: condvar
"Axel Dörfler" <[email protected]>
| Newsgroups | gmane.os.openbeos.kernel.devel |
|---|---|
| Message-ID | <40374026221-BeMail@zon> |
Ingo Weinhold <bonefish-CFLBMwTPW48UNGrzBIF7/[email protected]> wrote: > On 2005-03-17 at 19:14:04 [+0100], Axel Dörfler wrote: > > to be able to efficiently implement a condvar mechanism (and > > similar > > things), it would be great to atomically release one semaphore > > while > > aquiring another. > Not having thought much about condition variables yet, I suppose > doing this > atomically is necessary since the implementation would require to be > able > to switch the semaphores in both directions, right? Not really, although our implementation should allow this :) There is a condvar implementation in the BeOS sample-code (portability/ condvar) where you can easily see how a) condvar works, and b) how complicated BeOS makes its implementation. > > Together with the new B_RELEASE_ALL flag, condvar could then be > > implemented very easily. > > > > The functionality is very trivial to implement, that's why I've > > already > > done it - the question is on how we make it public. > > There are basically 3 possibilities: > > 1) keep it private for R1 > > 2) (the messy version) add another flag to acquire_sem_etc() that > > reinterpretes the "count" parameter as semaphore to be released - > > this > > has the advantage that no new system call is added; > System calls are cheap, so this isn't a valid advantage. I meant "advantage" in the sense that it's closer to R5/Zeta. > > 3) (the clean version) add a new pair of system calls: switch_sem() > > and > > switch_sem_etc() (other naming suggestions are welcome). > > Applications > > using these functions would not run on R5 or Zeta anymore. > I don't really see anything that speaks for 2), so I fully agree to > go with > 3). In principle this doesn't even collide with 1). So, why not > introduce > the functions, but keep them private (or document them being > private). Okay, good idea. I'll add them and make them semi-public; ie. I defer the final decision to a later point :-) Bye, Axel. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click