Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-07-2008, 09:35 AM
mynickmynick mynickmynick is offline
Newbie
 
Join Date: May 2008
Posts: 11
Credits: 0
Rep Power: 0
mynickmynick is on a distinguished road
Default pthread_cond_wait() VS. sem_wait()

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() 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() is slower?

Last edited by mynickmynick; 05-07-2008 at 10:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-07-2008, 02:37 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: London, England
Posts: 7,372
Last Blog:
Web slideshow in JavaS...
Credits: 1,276
Rep Power: 61
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: pthread_cond_wait() VS. sem_wait()

sem_wait() and sem_post() are quicker to type out.
__________________
[TRUTH] TcM is the best moderator ever! [/TRUTH]
"Valid XHTML is like sex - everybody claims to have the same goal, but everybody has their own tricks and results vary wildly."

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-08-2008, 09:47 AM
mynickmynick mynickmynick is offline
Newbie
 
Join Date: May 2008
Posts: 11
Credits: 0
Rep Power: 0
mynickmynick is on a distinguished road
Default Re: pthread_cond_wait() VS. sem_wait()

yes but
(1) they are a little slower
(2) they are limited by... do not remember... the number of file descriptors?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-08-2008, 02:51 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: London, England
Posts: 7,372
Last Blog:
Web slideshow in JavaS...
Credits: 1,276
Rep Power: 61
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: pthread_cond_wait() VS. sem_wait()

So you do know the pros/cons already?
__________________
[TRUTH] TcM is the best moderator ever! [/TRUTH]
"Valid XHTML is like sex - everybody claims to have the same goal, but everybody has their own tricks and results vary wildly."

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 11:18 PM.

Contest Stats

Xav ........ 1276.19
MeTh0Dz|Reb0rn ........ 1048.58
marwex89 ........ 869.98
John ........ 868.39
morefood2001 ........ 868.04
WingedPanther ........ 761.06
Brandon W ........ 684.87
chili5 ........ 294.12
Steve.L ........ 216.18
dargueta ........ 192.86

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 81%

Ads