Thursday, 15 September 2011

os161 - How semaphore value is checked using '==' operator? -



os161 - How semaphore value is checked using '==' operator? -

a semaphore declared , created --

static struct semaphore *done; done = sem_create("done",0); // semaphore value initialized 0

now happens when,

if(done==null) { //something done here... }

the if status executed above ? since done set 0 statements within if block executed ?

done pointer semaphore, , status done==null checks whether creation of new semaphore succeeded, in case done hold address of new semaphore, or failed, in case done hold null.

in short, status not check state of semaphore, if created @ all.

semaphore os161

No comments:

Post a Comment