DosExitCritSec (OS/2 1.x)

From EDM2
Jump to: navigation, search

This call restores normal thread dispatching for the current process.

Syntax

DosExitCritSec ()

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 485 ERROR_CRITSEC_UNDERFLOW

Remarks

A count is maintained of the number of times a DosEnterCritSec request is made without a corresponding DosExitCritSec. The count is incremented by DosEnterCritSec and decremented by DosExitCritSec. Normal thread dispatching is not restored until the count is 0.

The outstanding DosEnterCritSec count is maintained in a word. If overflow occurs, the count is set to the maximum value, no operation is performed, and the request returns with an error.

Bindings

C

#define INCL_DOSPROCESS

USHORT  rc = DosExitCritSec(VOID);

USHORT  rc;            /* return code */

MASM

EXTRN  DosExitCritSec:FAR
INCL_DOSPROCESS     EQU 1

CALL   DosExitCritSec

Returns WORD

Example Code

This example enters a section that will not be pre-empted, performs a simple task, and then exits quickly.

#define INCL_DOSPROCESS

  DosEnterCritSec();   /* Enter critical code section */
  flag = TRUE;         /* Perform some work */
  DosExitCritSec();    /* Exit critical code section */