[comp.unix.internals] Trouble using semctl

ndunstan@gara.une.oz.au (Neil Dunstan) (02/26/91)

semctl( semarray_id, 0, GETNCNT, 0 ) sometimes returns 0 unexpectedly.

I'm using it in a loop to test when a process has been released from a semaphore
queue. i.e.

oldcount = semctl( semarray_id, 0, GETNCNT, 0 )
while( (newcount = semctl( semarray_id, 0, GETCNT, 0 )) != oldcount-1 )
	semop( ... /* increase semaphore value by one */

Does anyone know why this shouldn't work?

Thanks.
Newsgroups: comp.unix.internals
Subject: Problem with semctl
Expires: 
References: 
Sender: 
Reply-To: neil@neumann.une.oz (Neil Dunstan)
Followup-To: 
Distribution: world
Organization: University of New England, Armidale, Australia
Keywords: 

semctl( semarray_id, 0, GETNCNT, 0 ) sometimes returns 0 unexpectedly.

I'm using it in a loop to test when a process has been released from a semaphore
queue. i.e.

oldcount = semctl( semarray_id, 0, GETNCNT, 0 )
while( (newcount = semctl( semarray_id, 0, GETCNT, 0 )) != oldcount-1 )
	semop( ... /* increase semaphore value by one */

Does anyone know why this shouldn't work?

Thanks.