Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

samaphore

stadzystadzy Member Posts: 1
i need help with this concept and i would gladly apprciate if soeone would enlighten me up a bit.
i have an understanding of this concept and in my own words a "semaphore" is used to signal the availability of a plentiful resource. The source of the resource adds one to the semaphore for each unused resource available. As resources are taken away, the count in the semaphore is decremented (one for each removed resource) until it reaches zero (meaning that no more resources are available). At his
point, any remaining consumers of the resource must wait until "semaphore" increments above zero, indicating that more resources are available.
but thats just it in case i have a problem like this:

In the unisex bathroom there are 3 toilet booths and one basin
with mirror. The rules for using the bathroom are as follows:

1) A single mixed queue of boys and girls is formed for
bathroom use. This queue operates on a first come first
served basis (no jumping the queue).
2) At any one time no more than 4 people
of the same sex may be inside the bathroom.

Make use of shared memory and semaphores to solve the unisex
bathroom problem. Write one code for BOYS to follow and one code
for GIRLS to follow so that the rules for bathroom use are observed.
Be sure to declare all your shared memory variables with their
initial values.

how can i approach it??
Sign In or Register to comment.