Discussion:
Semaphore Rules
(too old to reply)
David Marcin
2005-10-11 18:51:49 UTC
Permalink
When a Create_Semaphore(name) is called twice with the same name from
the same process without calling Destroy_Semaphore(sem) in between, what
should happen.

Should we return -1 as an error, or should we return the semaphore
descriptor for the requested semaphore? If we return the semaphore
descriptor should we treat the process as if it has two references to
this semaphore, or should we keep the limit to one semaphore reference
per process?
Iulian Neamtiu
2005-10-11 19:14:01 UTC
Permalink
Post by David Marcin
When a Create_Semaphore(name) is called twice with the same name from
the same process without calling Destroy_Semaphore(sem) in between, what
should happen.
Should we return -1 as an error, or should we return the semaphore
descriptor for the requested semaphore?
I don't think we test this scenario. Do whatever you think is easier.
In Unix there's an extra parameter for semaphore creation that
forces Create_Semaphore to return error if it's called twice with the same
name, but our implementation is simpler.
Post by David Marcin
If we return the semaphore
descriptor should we treat the process as if it has two references to
this semaphore, or should we keep the limit to one semaphore reference
per process?
Don't increment the reference count, otherwise you might never get the
refcount to get down to 0.

Iulian

Loading...