Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   sem_wait()/post() Vs. pthread_cond_wait()/broadcast() (http://www.programmingforums.org/showthread.php?t=15790)

mynickmynick May 7th, 2008 10:39 AM

sem_wait()/post() Vs. pthread_cond_wait()/broadcast()
 
What are advantages/disadvantages of using

sem_wait() and sem_post() instead of
pthread_cond_wait() and pthread_cond_broadcast()

for sincronizing pthreads?

I guess but please correct me:

Advantages:
(1) sem_wait()/post() are more flexible and do not need to be surrounded by mutex lock/unlock
(2) as a consequence sem_wait() can be used inside signal handlers or async call backs (pthread_cond need pthread_mutex which is not signal handler safe)

Disadvantages:
(1) sem_wait()/post() are slower? How much slower?


All times are GMT -5. The time now is 4:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC