This call disables thread switching for the current process.
DosEnterCritSec
rc (USHORT) - return
DosEnterCritSec causes other threads in the process to block themselves and give up their time slice. After a DosEnterCritSec request is made, no dynamic link calls should be made until the corresponding DosExitCritSec call is completed.
If a signal occurs, thread 1 begins execution to process the signal even though another thread in the process has a DosEnterCritSec active. (Thread 1 of a process is its initial thread of execution, not a thread created with the DosCreateThread call.) Any processing done by thread 1 to satisfy the signal must not include accessing the critical resource intended to be protected by the DosEnterCritSec request.
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.
A thread can also execute code without having to give up time slices to other threads in its process if it requests a priority class that is higher than those of the other threads. A thread's priority is examined and changed with DosGetPrty and DosSetPrty.