Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Thread Synchronization

Thread synchronization can be separated into 3 groups as follows:

  1. Mutex - mutual exclusion synchronization. The same thread that gets the mutex must release it.

    ctThrdMutexInit

    Initialize a mutex.

    ctThrdMutexGet

    Acquire the mutex. Wait until available.

    ctThrdMutexTry

    Acquire the mutex immediately or return.

    ctThrdMutexRel

    Release the mutex, permitting other threads to contend for it.

    ctThrdMutexCls

    Close the mutex, making it in active.

  2. Block - a block differs from a mutex in two significant respects
    1. It may be released by a thread other than the thread that acquired it.
    2. A timeout value may be specified which causes a ctThrdBlockGet() or ctThrdBlockWait() to return with an NTIM_ERR (156) if the call could not succeed in the specified timeout interval. Like a mutex, a block can be acquired by only one thread at a time.

    ctThrdBlockInit

    Initialize a block.

    ctThrdBlockGet

    Acquire the block. Wait until available or timeout expires.

    ctThrdBlockWait

    Wait until block is free or timeout expires. Block is NOT acquired by the thread.

    ctThrdBlockRel

    Release the block.

    ctThrdBlockCls

    Close the block, making it inactive.

  3. Semaphore - a semaphore is a synchronization object that may be acquired by more than one thread at a time, and may be released by a thread that has not acquired it.

    ctThrdSemapInit

    Initialize a semaphore.

    ctThrdSemapGet

    Get one unit of semap. The thread will block indefinitely until a unit of the semaphore is available.

    ctThrdSemapTry

    Same as ctThrdSemapGet() except that if no unit of the semaphore is available, NTIM_ERR (156) is returned immediately.

    ctThrdSemapRel

    Release one unit of the semaphore.

    ctThrdSemapCls

    Close the semaphore, making it inactive.

TOCIndex