logo       

Re: Diffenrence Completion and Semaphore: msg#00004

Subject: Re: Diffenrence Completion and Semaphore
On Fri, 2006-05-19 at 12:41 +0900, minchan Kim wrote:
> Thanks to your commenting.
> 
> I understand your point.  But I see the book "Understanding of the
> Linux Kernel", it says "Semaphore happen race condition problem in the
> SMP envirioment since call up and down concurrency. But Completion
> isn't"
> 
> I don't understand it. Do you understand it?

I think they mean that semaphores will cause exclusion (but really, use
mutexes, much easier and they are replacing semaphores), while
completions do not cause exclusion...

eg you can use a mutex to prevent concurrent access (as the code snippet
I gave you before shows), while a completion really doesn't do that.
The book too artifically tries to tie these concepts together by trying
to explain the difference in a micro scale, but that's wrong.
They are ENTIRELY different things. Not even comparable. So saying
"they're different in <this tiny detail>" sort of implies they're
similar constructs in many other ways. They are not. Don't even think
they are. 

(having said that, some people used to abuse semaphores to do a
completion type of behavior, which is where the confusion is coming
from, but just don't do that or even focus on that, it's like using the
back of a book to drive a nail in the wall and then ask "what's the
difference between a book and a hammer since I now have both". The
answer is "who cares. Just use the hammer for your own sanity" :)


<Prev in Thread] Current Thread [Next in Thread>