On Sat, Jun 22, 2002 at 06:04:11PM +0300, Momchil Velikov wrote: > >> Hell if I can find any difference. Except that semaphores (in Linux > >> (the kernel)) have machine dependent implementations and are likely to > >> be much faster. > Jan> There is no "down" for completion. For semaphore, if you "up", exactly > Jan> one "down" succeeds. For completion, it you "compelte", all "wait"s > Jan> succeed from now on. You have to reinitialize it. And initializing is > Jan> not atomic. So completion is really just an encapsulation of waitqueue > Jan> whith conditional variable to simplify wait_on_event. > Not true. See the handling of the ``done'' field. It is uncremented > in ``complete'' and decremented in ``wait_for_completion''. Just like > the semaphore count. > Jan> Anyway, you CAN'T use completion for mutual exclusion and semaphores are > Of course, you CAN :) Just initialize it to 1 and than > ``wait_for_completion'' is equivalent to lock and ``complete'' is > equivalent to unlock. Oh, I see. I just briefly looked at that funciton and overlooked that. However then I don't know what the hell is it good for. Since I can imagine a situation where N processes waits on 1 to complete something and when it's done, all of them can continue (eg. some data are now available). But that can't be hadnled by this. But every situation where completion can be used can be handled by semaphores too. Then I don't know what they are good for. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/