Discussion:
Max number of semaphores?
(too old to reply)
William Francis Cladek
2005-03-06 23:57:59 UTC
Permalink
Maybe I'm completely missing something here, or maybe I'm just stating the
obvious, but these lines in the project description make no sense to me:

"Your operating system should be able to handle at least 20 (thus N = 20)
semaphores whose names may be up to 25 characters long. If there are no
semaphores left (i.e., there were 20 semaphores with unique names already
given), -1 must be returned indicating an error."

How does it handle 20 or more, but it returns an error if 20 are already
being used? The fact that "at least" in the project description made me
think that's not a typo, but maybe it is...

Will
Tom Brubaker
2005-03-07 00:58:54 UTC
Permalink
I took this to mean that your operating system can have a maximum number of
semaphores, but the smallest you should design this number to be is 20.
Iulian Neamtiu
2005-03-07 21:07:54 UTC
Permalink
Post by Tom Brubaker
I took this to mean that your operating system can have a maximum number of
semaphores, but the smallest you should design this number to be is 20.
That's correct. You can support 25 semaphores for instance, anything
greater than 20 is fine. But probably sticking to the basic 20 is best.

If you're out of semaphores, meaning you're using 20 (or 25 for that
matter) already and get a Create_Sempahore() request, you should return -1.

Note however that '20 sempahores in use' is not the same thing as 20
calls to Create_Sempahore(), since you can have a Destroy_Semaphore() in
between and that's going to decrease the # of semaphores currently in use.

Iulian

Continue reading on narkive:
Loading...