P. 1
Multi Threaded Programming Guide (SUN)

Multi Threaded Programming Guide (SUN)

|Views: 694|Likes:

More info:

Published by: arunodoy_dasgupta3078 on Aug 14, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/19/2011

pdf

text

original

Usesem_wait(3RT)toblockthecallingthreaduntilthesemaphorecountpointedtobysem
becomesgreaterthanzero,thenatomicallydecrementthecount.

sem_waitSyntax

int sem_wait(sem_t *sem);

#include

sem_t sem;

int ret;

ret = sem_wait(&sem); /* wait for semaphore */

sem_waitReturnValues

sem_wait()returnszeroaftercompletingsuccessfully.Anyotherreturnvalueindicatesthatan
erroroccurred.Whenanyofthefollowingconditionsoccurs,thefunctionfailsandreturnsthe
correspondingvalue.

EINVAL

Description:sempointstoanillegaladdress.

EINTR

Description:Asignalinterruptedthisfunction.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->