Sponsored link Serve your customers, not your servers, with VERIO Linux VPS. Full-access test-drive here. |
Mutex is not a semaphoreMutex is not a semaphorePosted Mar 20, 2008 5:22 UTC (Thu) by ikm (subscriber, #493)Parent article: Generic semaphores
Somehow I feel that the "mutex vs semaphore" distinction would have been nice to have from the start — this way the question "why are semaphores still being used at all?" would never arise at all. I'd like to notice that one use of a semaphore as of a "fifo for token-like objects", that is, the one where the initial value is usually 0 and where one side initiating pushes causes another side to initiate the same amount of pops is not mentioned in this article at all, while e.g. for me it was always the primary use for semaphores (when I had dedicated mutex primitives for handling mutual exclusions, that is).
(Log in to post comments)
That is, semaphore is not a mutex Posted Mar 20, 2008 5:49 UTC (Thu) by ikm (subscriber, #493) [Link] Subject should've been the other way around, sorry :) Point is, stop using them interchangeably!
Mutex is not a semaphore Posted Mar 22, 2008 3:22 UTC (Sat) by willy (subscriber, #9762) [Link] > I'd like to notice that one use of a semaphore is of a "fifo for > token-like objects", that is, the one where the initial value is > usually 0 The semaphore implementations (both current and new) do support this, but we have few if any users of it currently in the kernel. We have the 'completion' API which sort-of does what you want (it's specialised for 'I am exiting now', but doesn't have to be used that way). My motivation was really not to correct mutex vs semaphore usage but to add new features to semaphores -- down_killable() and down_timeout() are the two I've added so far, each taking very few additional lines of code. I now suspect, having read over the completion code, that completions could be rewritten in terms of my new semaphore implementation. I'll look into it later. Matthew Wilcox
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.