On Fri, 2006-05-19 at 10:47 +0900, minchan Kim wrote:
> Hello. I am a kernel newbie.
> I knew the kernel-mentor site today.
> Please, I hope that mentors help me to have a question in the future.
>
> I had a one question.
>
> I know new feature "Completions" in Linux kernel 2.6 , but I don't
> know difference semaphore and completion.
> I wonder that When i use completion instead of semaphore ?
they're different usage patterns:
the basic completion pattern is when you set something up that at some
point in the future gets finished, for example, you could schedule a
disk IO, and when the IO actually finishes, the completion would be
called. Eg there generally is a "task" that at some point gets
'completed'.
A semaphore.. isn't used much anymore, a mutex is used instead.
A mutex is basically a short term exclusion tool, eg the pattern is
<take mutex>
<do some actions>
<release mutex>
unlike completions, there is a strong sense of "who takes the mutex
releases it", and the there is a well defined task "in the middle",
while for completions it is "something else finishes it".
Does this help?
|