Diff between Semaphore and Completion Variable

Diff between Semaphore and Completion Variable

am 06.06.2006 13:57:35 von Rajat Jain

Hi,

I would appreciate if some one could explain the difference between
"completion" variables and the semaphores in Linux.

As far as I can understand, both are used to provide synchronization
among kernel threads. Both have similar mechanism i.e. one or more
tasks wait on the completion variable (or semaphore) while another
task holds it and does some work (in critical section). When the task
holding the completion variable (or semaphore) is done, it signals the
other task using "complete" (or "up"). This would cause the waiting
tasks to wait up.

So why have two different things to do the same thing?

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Diff between Semaphore and Completion Variable

am 06.06.2006 21:41:22 von Arjan van de Ven

On Tue, 2006-06-06 at 17:27 +0530, Rajat Jain wrote:
> Hi,
>
> I would appreciate if some one could explain the difference between
> "completion" variables and the semaphores in Linux.
>
> As far as I can understand, both are used to provide synchronization
> among kernel threads. Both have similar mechanism i.e. one or more
> tasks wait on the completion variable (or semaphore) while another
> task holds it and does some work (in critical section). When the task
> holding the completion variable (or semaphore) is done, it signals the
> other task using "complete" (or "up"). This would cause the waiting
> tasks to wait up.
>
> So why have two different things to do the same thing?

they don't do the same thing just like a hammer and a couch are two
different things.

a completion is for doing "wait until this event is finished", while a
semaphore (well don't use semaphores, use a mutex nowadays) is for
providing mutual exclusion for a piece of data.
Totally different things.


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Diff between Semaphore and Completion Variable

am 07.06.2006 10:15:46 von cheng long

> I would appreciate if some one could explain the difference between
> "completion" variables and the semaphores in Linux.
1) In semaphore, there is a variable, P() first test the variable and make the
process sleep when it equals 0. In condition variable, there is no variable,
instead, condition is external variable defined by process. The variable
is tested by the process itself. In another word, sleeping is explicit in
contion variable while implicit in sempaphore.

2) Whether there are waiting processes, V() alway increases the variable,
however,signal() of contition variable will do nothing when there is no waiting
process.

Hope this helpful !
Good Luck!

Regards,
Cheng
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Diff between Semaphore and Completion Variable

am 08.06.2006 09:26:12 von Gaurav Dhiman

On 6/7/06, Arjan van de Ven wrote:
> On Tue, 2006-06-06 at 17:27 +0530, Rajat Jain wrote:
> > Hi,
> >
> > I would appreciate if some one could explain the difference between
> > "completion" variables and the semaphores in Linux.
> >
> > As far as I can understand, both are used to provide synchronization
> > among kernel threads. Both have similar mechanism i.e. one or more
> > tasks wait on the completion variable (or semaphore) while another
> > task holds it and does some work (in critical section). When the task
> > holding the completion variable (or semaphore) is done, it signals the
> > other task using "complete" (or "up"). This would cause the waiting
> > tasks to wait up.
> >
> > So why have two different things to do the same thing?
>
> they don't do the same thing just like a hammer and a couch are two
> different things.
>
> a completion is for doing "wait until this event is finished", while a
> semaphore (well don't use semaphores, use a mutex nowadays) is for
> providing mutual exclusion for a piece of data.
> Totally different things.


Where can I find the refference to completion variables in kernel .....

regards,
Gaurav

>
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/kernelnewbies/
> FAQ: http://kernelnewbies.org/faq/
>
>


--
Gaurav
Email: gauravd.chd@gmail.com
--------------------------------------------
Read my Linux Kernel blog at: http://lkdp.blogspot.com/
--------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Diff between Semaphore and Completion Variable

am 08.06.2006 15:17:24 von Arjan van de Ven

>
> Where can I find the refference to completion variables in kernel .....
>

they are not completion variables in the posix sense.


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs