semaphore program

view story

http://www.linuxquestions.org – Hi All I running one simple semaphore application. I have 2 threads , where one thread is waiting for sem post to happen so I have put sem_wait & other thread is doing sem_post .When I come keeping delay (sleep of 1 sec) I find scheduling is happening properly .But without delay I am finding it strange behaviour i.e. scheduling is not in the proper way as it was when I kept delay of 1 second. I feel sem_wait should have been blocked & the print "after wait" should only execute when sem post happens I have kept both program as well as output also . Can anyone tell me why (HowTos)