eyBuildLib API Reference : eyBuildLib
ebsemlib - semaphore library
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
This library support Win32, POSIX OS and VxWorks.
ebsemlib.h
ebSemInit( ) - creates an unnamed semaphore with specifical count
int ebSemInit ( EBSEM_ID * semid, size_t initial_count )
This routine creates a semaphore with specifical count initial_count.
OK/ERROR
ebSemWait( ) - lock (take) a semaphore, blocking if not available
int ebSemWait ( EBSEM_ID * semid )
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.
OK/ERROR
ebSemWaitTimeout( ) - lock (take) a semaphore with a timeout value
int ebSemWaitTimeout ( EBSEM_ID * semid, /* semaphore ID */ unsigned long timeout /* millisecond */ )
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.
OK, or ERROR if an error occur or wait timeout.
ebSemPost( ) - unlock (give) a semaphore
int ebSemPost ( EBSEM_ID * semid )
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( ).
OK/ERROR
ebSemDestroy( ) - destroy an unnamed semaphore
int ebSemDestroy ( EBSEM_ID * semid )
This routine is used to destroy the unnamed semaphore indicated by semid.
OK/ERROR
ebSemInit( ) - creates an unnamed mutex
int ebMutexInit ( EBMUTEX_ID * mutex )
This routine creates an unnamed mutex.
OK/ERROR
ebMutexLock( ) - get ownership of the specified mutex object
int ebMutexLock ( EBMUTEX_ID * mutex )
This routine is get ownership of the specified mutex object.
OK/ERROR
ebMutexUnlock( ) - giveup ownership of the specified mutex object
int ebMutexUnlock ( EBMUTEX_ID * mutex )
This routine is giveup ownership of the specified mutex object.
OK/ERROR
ebMutexDestroy( ) - destroy an unnamed mutex
int ebMutexDestroy ( EBMUTEX_ID * mutex )
This routine is to destroy an unnamed mutex.
OK/ERROR