Scroll to navigation

Ns_Master(3aolserver) AOLserver Library Procedures Ns_Master(3aolserver)


Ns_MasterLock, Ns_MasterUnlock - Enter and leave the single master critical section lock


#include "ns.h"




The single master critical section lock is used throughout the core server to protect portions of code from being run by more than one thread at a time. These are convenience functions which actually make calls to Ns_CsEnter and Ns_CsLeave to perform the locking and unlocking function.

You should not use these functions in your modules. To protect critical sections in your modules you should create and initialize your own named locks, then wrap your critical sections with calls to Ns_CsEnter and Ns_CsLeave.

Enter the single master lock. The thread that holds this lock is guaranteed exclusive access to the section of code that follows the call to Ns_MasterLock. Other threads that attempt to enter the master critical section while another thread owns the master lock will block until the owning thread releases the master lock.

Be extremely careful with code you place within the master critical section. If the thread that owns the master lock blocks for any reason while in the master critical section, other threads that need to enter that section of code will block until the master lock is released.

Leave the single master critical section. The thread that owns the lock must release it after the critical section of code has completed so that other threads may execute the critical section code.


nsd(1), info(n), Ns_CsEnter(3), Ns_CsLeave(3)


4.0 AOLserver