eyBuildLib API Reference : eyBuildLib

ebsemlib

NAME

ebsemlib - semaphore library

ROUTINES

ebSemInit( ) - creates an unnamed semaphore with specifical count
ebSemWait( ) - lock (take) a semaphore, blocking if not available
ebSemWaitTimeout( ) - lock (take) a semaphore with a timeout value
ebSemPost( ) - unlock (give) a semaphore
ebSemDestroy( ) - destroy an unnamed semaphore
ebSemInit( ) - creates an unnamed mutex
ebMutexLock( ) - get ownership of the specified mutex object
ebMutexUnlock( ) - giveup ownership of the specified mutex object
ebMutexDestroy( ) - destroy an unnamed mutex

DESCRIPTION

This library support Win32, POSIX OS and VxWorks.

INCLUDE

ebsemlib.h


eyBuildLib : Routines

ebSemInit( )

NAME

ebSemInit( ) - creates an unnamed semaphore with specifical count

SYNOPSIS

int ebSemInit
    (
    EBSEM_ID * semid,
    size_t     initial_count
    )

DESCRIPTION

This routine creates a semaphore with specifical count initial_count.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebSemWait( )

NAME

ebSemWait( ) - lock (take) a semaphore, blocking if not available

SYNOPSIS

int ebSemWait
    (
    EBSEM_ID * semid
    )

DESCRIPTION

This routine locks the semaphore referenced by sem only if the semaphore is currently not locked; that is, if the semaphore value is currently positive. Otherwise, it does not lock the semaphore. In either case, this call returns immediately without blocking.

Upon return, the state of the semaphore is always locked (either as a result of this call or by a previous ebSemWait( )). The semaphore will remain locked until ebSemPost( ) is executed and returns successfully.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebSemWaitTimeout( )

NAME

ebSemWaitTimeout( ) - lock (take) a semaphore with a timeout value

SYNOPSIS

int ebSemWaitTimeout
    (
    EBSEM_ID *    semid,      /* semaphore ID */
    unsigned long timeout     /* millisecond */
    )

DESCRIPTION

This routine locks (takes) a semaphore with a timeout value. If them semid is illegal or get a semaphore this call returns immediately without blocking. Otherwise this call will block and at most timeout millisecond.

RETURN

OK, or ERROR if an error occur or wait timeout.

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebSemPost( )

NAME

ebSemPost( ) - unlock (give) a semaphore

SYNOPSIS

int ebSemPost
    (
    EBSEM_ID * semid
    )

DESCRIPTION

This routine unlocks the semaphore referenced by semid by performing the semaphore unlock operation on that semaphore.

If the semaphore value resulting from the operation is positive, then no tasks were blocked waiting for the semaphore to become unlocked; the semaphore value is simply incremented.

If the value of the semaphore resulting from this semaphore is zero, then one of the tasks blocked waiting for the semaphore will return successfully from its call to ebSemWait( ).

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebSemDestroy( )

NAME

ebSemDestroy( ) - destroy an unnamed semaphore

SYNOPSIS

int ebSemDestroy
    (
    EBSEM_ID * semid
    )

DESCRIPTION

This routine is used to destroy the unnamed semaphore indicated by semid.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebSemInit( )

NAME

ebSemInit( ) - creates an unnamed mutex

SYNOPSIS

int ebMutexInit
    (
    EBMUTEX_ID * mutex
    )

DESCRIPTION

This routine creates an unnamed mutex.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebMutexLock( )

NAME

ebMutexLock( ) - get ownership of the specified mutex object

SYNOPSIS

int ebMutexLock
    (
    EBMUTEX_ID * mutex
    )

DESCRIPTION

This routine is get ownership of the specified mutex object.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebMutexUnlock( )

NAME

ebMutexUnlock( ) - giveup ownership of the specified mutex object

SYNOPSIS

int ebMutexUnlock
    (
    EBMUTEX_ID * mutex
    )

DESCRIPTION

This routine is giveup ownership of the specified mutex object.

RETURN

OK/ERROR

SEE ALSO

ebsemlib


eyBuildLib : Routines

ebMutexDestroy( )

NAME

ebMutexDestroy( ) - destroy an unnamed mutex

SYNOPSIS

int ebMutexDestroy
    (
    EBMUTEX_ID * mutex
    )

DESCRIPTION

This routine is to destroy an unnamed mutex.

RETURN

OK/ERROR

SEE ALSO

ebsemlib