This call obtains a Fast-Safe (FS) RAM semaphore and records the current owner for potential cleanup by a DosExitList routine.
DosFSRamSemRequest
FSRamSemStructure (PDOSFSRSEM) - input
fs_Length (USHORT)
Before the initial call to DosFSRamSemRequest, this entire structure must be initialized to zero and its length set to 14. Other than fs_Client, the caller should not modify any fields in this structure.
Value
When DosFSRamSemRequest is called, it checks the status of the semaphore. If it is unowned, then DosFSRamSemRequest sets it owned, increments fs_UseCount, and returns immediately to the caller.
If the semaphore is owned, the caller has the option to block until the semaphore is no longer owned. The unblocking of a DosFSRamSemRequest is "level triggered" because it does not actually return unless the semaphore remains clear until the affected thread can be redispatched to claim it successfully. The Timeout parameter can be used to place an upper bound on the amount of time to block before returning, even though the semaphore remains owned.
When the thread is done with the protected resource, it calls DosFSRamSemClear. DosFSRamSemClear decrements fs_UseCount. Recursive requests for FS RAM semaphores are supported by the use count, which keeps track of the number of times the owner has issued a DosFSRamSemRequest without a corresponding DosFSRamSemClear. If the call to DosFSRamSemClear decrements the use count to zero, the semaphore is set unowned, and any threads that were blocked waiting for the semaphore resume execution.
The 16-bit field fs_Client is not interpreted by the FS RAM semaphore calls. Instead, it provides the caller with a means of identifying the resource being accessed by the owner of the semaphore. This field is initialized to zero when a FS RAM semaphore is first acquired. The owner may place values into this field that describe the resource. These values can be used by an exit list handler to determine the appropriate cleanup action.
When a process terminates while owning a FS RAM semaphore, any routines
in the exit list maintained by DosExitList
are given control. These routines take appropriate steps to guarantee
the integrity of resources owned by the process. To clean up a resource
protected by a FS RAM semaphore, DosFSRamSemRequest is called to gain ownership
of the semaphore. When issued during exit list processing ,
DosFSRamSemRequest examines the semaphore to determine if the semaphore
is owned by the active process. It then forces the owning thread ID to be
equal to the current thread ID and sets
fs_Count = 1. This allows the exit list routine to be programmed without
any FS RAM semaphore handling instructions. When the exit list routine
has completed its operations, it restores the resource for use by others
by issuing DosFSRamSemClear.