semaphore in linux with maxcount and time out
I am porting a Windows application to Linux. I need to set a time out for the semaphore wait operation. I did it with sem_trywait in a loop. Is there a better way?
How to set set the maximum count for a semaphore ? Anybody has a wrapper written with these functionalities implemented ?
"man sem_wait" gives sem_timedwait which seems to do the job.
It's easy to get the current semaphore value with "sem_getvalue" and then don't "sem_post" if the value is greater than the max you need.
|All times are GMT -5. The time now is 09:11 AM.|