EnterCritSec

Prevents all other threads in the NLM from being scheduled

Local Servers:blocking
Remote Servers:N/A
Classification:3.x, 4.x, 5.x, 6.x
Service:Thread

Syntax

  #include <nwthread.h>  
   
  int EnterCritSec  (void); 
  

Return Values

The following table lists return values and descriptions.

Value

Hex

Name

Description

0

(0x00)

ESUCCESS

Threads were suspended in a critical section.

Remarks

The EnterCritSec function suspends all the other threads in the NLM.

After executing EnterCritSec, the current thread runs exclusively until it calls ExitCritSec. The ExitCritSec function makes the other threads in the NLM runnable again.

EnterCritSec and ExitCritSec can be nested. EnterCritSec maintains a count of the number of outstanding EnterCritSec requests. The count is increased with each call to EnterCritSec and decreased with each call to ExitCritSec. To restore normal thread dispatching ExitCritSec must be called once for each call to EnterCritSec.

The maximum number of concurrent critical sections is 4 billion.

Since NetWare 3.x, 4.x, 5.x, and 6.x are nonpreemptive operating systems, NLM applications very rarely need to use this function. The only time it is needed is when a critical section of code calls a function which might relinquish control.

Additionally, use of the EnterCritSec function should be avoided in favor of using locks or semaphores.

NOTE:If a new thread is started while the NLM is in a critical section, the new thread is also in the critical section. If the new thread is started after a call to EnterCritSec but before a corresponding call to ExitCritSec, the new thread is immdeately suspended.

See Also

ExitCritSec