Hi
I'm getting a problem while removing semaphore from system.
Before removing semaphore I'm checking the usage count of a smaphore.
// checking usage count
usage_count = semctl(sem_ptr->semid, 1, GETVAL, NULL);
if( usage_count 1 )
// return don't remove semaphore
else
// remove semaphore
If usage count is more than 1 then I'm not removing it.It means that at
this time there are more than one threads waiting for resource.
The problem is coming when after checking the usage_count = 1 if
usage_count becomes 2.
then problem is coming.This operation is not atomic.the usage_count
should not be 2 while removing semaphore.
Please anybody can tell me that How to avoid this problem.
Regards,
Pawan