Creating a semaphore

To create a local semaphore, simply declare it:

      // local semaphore
      TLocalSemaphore* localSem = new TLocalSemaphore();
To create a recoverable semaphore and share it among tasks, one task must declare the semaphore and stream it to the others:

    TRecoverableSemaphoreHandle* recoverableSem = new TRecoverableSemaphoreHandle(); *recoverableSem => stream;
To use the recoverable semaphore, a cooperating task must read the semaphore from the same stream:

      TRecoverableSemaphoreHandle* recoverableSem = new TRecoverableSemaphoreHandle();
      *recoverableSem <= stream;
CAUTION When you initialize a recoverable semaphore handle from a stream, it is possible that the semaphore to which it refers has already been deleted. In this case, an attempt to acquire the semaphore generates an exception.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker