|
-
October 4th, 2010, 08:00 AM
#5
Re: semaphores & Concurrent Programming
 Originally Posted by FeralDruidonWoW
Code:
semaphore max_capacity;
semaphore woman;
semaphore man;
semaphore mutex;
Hm, I don't know C--, but that doesn't look quite right to me. If all the conditions (access criteria) have their own keys and these keys are up for grasp for any client thread without any syncronization, then you would have a race condition. On the other hand, if both woman and man semaphores need to wait for one another like above, then you have a deadlock.
Probably the easiest way is to have each client thread access through the semaphore, and seperate 'mutual exclusion' of men and women out of the threading logic so that in this way, the real mutex object is the key to the tolilet like it is supposed to be
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|