Difference between revisions of "DosEnterCritSec (OS/2 1.x)"
m (Ak120 moved page OS2 API:CPI:LEGACY:DosEnterCritSec to DosEnterCritSec (OS/2 1.x)) |
m |
||
Line 1: | Line 1: | ||
− | |||
This call disables thread switching for the current process. | This call disables thread switching for the current process. | ||
==Syntax== | ==Syntax== | ||
− | + | DosEnterCritSec ( ) | |
− | DosEnterCritSec | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
==Return Code== | ==Return Code== | ||
rc (USHORT) - return | rc (USHORT) - return | ||
− | |||
Return code descriptions are: | Return code descriptions are: | ||
+ | * 0 NO_ERROR | ||
+ | * 484 ERROR_CRITSEC_OVERFLOW | ||
− | |||
− | |||
==Remarks== | ==Remarks== | ||
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. | 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. | ||
Line 56: | Line 49: | ||
Returns WORD | Returns WORD | ||
</PRE> | </PRE> | ||
− | |||
− | |||
− | |||
− | [[Category: | + | [[Category:Dos]] |
Revision as of 11:28, 1 March 2017
This call disables thread switching for the current process.
Syntax
DosEnterCritSec ( )
Return Code
rc (USHORT) - return
Return code descriptions are:
- 0 NO_ERROR
- 484 ERROR_CRITSEC_OVERFLOW
Remarks
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.
Example Code
C Binding
#define INCL_DOSPROCESS USHORT rc = DosEnterCritSec(VOID); USHORT rc; /* return code */
This example enters a section that will not be pre-empted, performs a simple task, and then exits quickly.
#define INCL_DOSPROCESS USHORT flag; DosEnterCritSec(); /* Enter critical code section */ flag = TRUE; /* Perform some work */ DosExitCritSec(); /* Exit critical code section */
MASM Binding
EXTRN DosEnterCritSec:FAR INCL_DOSPROCESS EQU 1 CALL DosEnterCritSec Returns WORD