Download RadiSys ARTIC960 Programmer`s Reference

Transcript
CloseSem—Close a Semaphore
CloseSem—Close a Semaphore
This service releases access to a semaphore and deletes the semaphore if no other
processes have access.
Functional Prototype
RIC_ULONG CloseSem (RIC_SEMHANDLE SemHandle,
RIC_ULONG
Reserved);
Parameters
SemHandle Input. Handle of semaphore to release.
Reserved
Input. Reserved parameter (must be 0).
Returns
RC_SUCCESS
RC_INVALID_HANDLE
RC_INVALID_RESERVED_PARM
RC_DEPENDENT_EVENTS
RC_INVALID_CALL
Remarks
If the close is issued by a process while other processes still have access to the semaphore,
the service removes access rights for the issuing process. When the last process with
access rights calls this service, the semaphore ceases to exist. See CreateSem—Create a
Semaphore on page 51 and OpenSem—Open a Semaphore on page 52 for more
information.
If a process is stopped or unloaded, the kernel closes all of its resources. It notifies,
through asynchronous notification, all other processes that shared those resources that the
process has gone away. If a process closes a mutual exclusion semaphore that it owns (that
is, it requested the semaphore last but has not released it), all processes waiting for the
semaphore are awakened with an error of RC_OWNER_CLOSED_SEM. This is done because
the code and data protected by the mutual exclusion semaphore may have been left in an
indeterminable state. When this happens, the semaphore count is reset to one, so the
semaphore can be re-requested if the application process knows that the protected code
and data is in a valid state.
Chapter 3: Base Kernel Services
53