DosFSRamSemClear

From EDM2
Jump to: navigation, search

This call releases ownership of a Fast-Safe (FS) RAM semaphore.

Syntax

DosFSRamSemClear (FSRamSemStructure)

Parameters

FSRamSemStructure (PDOSFSRSEM) - input
Address of the FS RAM Semaphore data structure. The content/format of this structure is shown in DosFSRamSemRequest.

Return Code

rc (USHORT) - return
Return code description is:
  • 0 NO_ERROR

Remarks

DosFSRamSemClear decrements fs_UseCount, which is incremented by DosFSRamSemRequest. Recursive requests for FS RAM semaphores are supported by this 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.

DosFSRamSemClear cannot be issued against a FS RAM semaphore that is owned by another thread.

Bindings

C

typedef struct _DOSFSRSEM { /* dosfsrs */
 
  USHORT cb;                /* Length of this structure (bytes) */
  PID    pid;               /* Process ID of owner or zero */
  TID    tid;               /* Thread ID of owner or zero */
  USHORT cUsage;            /* Reference count */
  USHORT client;            /* 16 bit field for use by owner */
  ULONG  sem;               /* OS/2 Ram Semaphore */
 
} DOSFSRSEM;

#define INCL_DOSSEMAPHORES

USHORT  rc = DosFSRamSemClear(FSRamSemStructure);

PDOSFSRSEM   FSRamSemStructure;  /* Address of structure */
USHORT       rc;                 /* return code */

MASM

DOSFSRSEM struc
  dosfsrs_cb      dw  ? ;length of this structure (bytes)
  dosfsrs_pid     dw  ? ;Process ID of owner or zero
  dosfsrs_tid     dw  ? ;Thread ID of owner or zero
  dosfsrs_cUsage  dw  ? ;reference count
  dosfsrs_client  dw  ? ;16 bit field for use by owner
  dosfsrs_sem     dd  ? ;OS/2 Ram Semaphore
DOSFSRSEM ends

EXTRN  DosFSRamSemClear:FAR
INCL_DOSSEMAPHORES  EQU 1

PUSH@  OTHER   FSRamSemStructure ;FS Ram Semaphore data structure
CALL   DosFSRamSemClear

Returns WORD

Example

This example requests a FS RAM semaphore and then clears it.

#define INCL_DOSSEMAPHORES

#define NOT_OWNED 0
#define START 0
#define START_LONG 0L
#define TIME_OUT 1000L

DOSFSRSEM SemStruct;
USHORT    rc;

   SemStruct.cb = sizeof(SemStruct);   /* Initialize FS Sem */
   SemStruct.pid = NOT_OWNED;
   SemStruct.tid = NOT_OWNED;
   SemStruct.cUsage = START;
   SemStruct.client = START;
   SemStruct.sem = START_LONG;

   if(!DosFSRamSemRequest(&SemStruct,     /* Address of structure */
                          TIME_OUT))      /* Timeout */
      rc = DosFSRamSemClear(&SemStruct);  /* Address of structure */