Re: Struct completion vs. semaphore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 21, 2002 at 05:11:26PM +0300, Momchil Velikov wrote:
> >>>>> "Alan" == Alan Stern <stern@rowland.org> writes:
> Alan> But you didn't answer my first question.  What are the essential
> Alan> differences between a struct completion and a semaphore?
> 
> 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.

There is no "down" for completion. For semaphore, if you "up", exactly
one "down" succeeds. For completion, it you "compelte", all "wait"s
succeed from now on. You have to reinitialize it. And initializing is
not atomic. So completion is really just an encapsulation of waitqueue
whith conditional variable to simplify wait_on_event.

The semaphores are much more complicated and much more widely used, thus
tjey are partly in assembly.

Anyway, you CAN'T use completion for mutual exclusion and semaphores are
not much good for waiting on completition (they are good for
producer-consumer, but that's something else)

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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux