DosExitCritSec is used following DosEnterCritSec to restore normal thread switching to the threads of a process.

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

The outstanding count is maintained in a word. If an underflow occurs (the count is decremented below zero), the count is set to zero, no operation is performed, and the request returns with ERROR_CRITSEC_UNDERFLOW.

ERROR_INVALID_THREADID is returned when an invalid attempt is made to exit a critical section of code in a signal handler or exception handler.

ERROR_INVALID_THREADID is also returned when a dynamic link library (DLL) routine incorrectly issues DosExitCritSec.


[Back] [Next]