Home | Contact | About | Search

Embedded Networking Consulting Login
emenu
emenu OS API emenu Profiler emenu MemTool emenu PCI emenu Reference emenu Links emenu
emenu emenu emenu emenu emenu emenu


Semaphores


semCreate ( )
Name: semCreate ( ) - creates a semaphore
Synopsis:
SEM_HANDLE semCreate
(
  u32 u32InitialCount /* initial count of new semaphore */
)
Description: Creates a counting semaphore with an initial count of u32InitialCount.
Include: sempaphore.h
Returns: The SEM_HANDLE of the newly created semaphore. Note that this function will not return if the semaphore cannot be created, instead the system will halt (during development) or reboot (if in the field) so there are no illegal values that can be returned.
See Also: semDestroy semTake semGive semGetCount

semDestroy ( )
Name: semDestroy ( ) - destroys a semaphore
Synopsis:
void semDestroy
(
  SEM_HANDLE semHandle /* semaphore to destroy */
)
Description: Deletes a semaphore. Be careful not delete a semaphore while there are any other threads waiting on it. To do this is undefined behavior.
Include: sempaphore.h
Returns: nothing
See Also: semCreate

semTake ( )
Name: semTake ( ) - takes a semaphore
Synopsis:
STATUS semTake
(
  SEM_HANDLE semHandle,            /* semaphore to take */
  u32        u32MillisecondsToWait /* number of milliseconds to wait */
)
Description: Takes a semaphore. If the current count is 0, the call blocks for u32MillisecondsToWait. The u32MillisecondsToWait parameter may be set to NO_WAIT to make a non blocking request or the value of WAIT_FOREVER can be used to block forever.

Note that this function will never return an error if WAIT_FOREVER is the parameter passed to u32MillisecondsToWait so there is no need to check for error status in that case.

Include: sempaphore.h
Returns: SEM_SUCCESS if the semaphore was successfully taken or SEM_TIMEOUT if the semaphore was unavailable to be taken in the requested time period.
See Also: semGive, semGetCount

semGive ( )
Name: semGive ( ) - increments a semaphore count
Synopsis:
void semGive
(
  SEM_HANDLE semHandle /* semaphore to increment the count of */
)
Description: Increments the count of the given semaphore.
Include: sempaphore.h
Returns: nothing
See Also: semTake, semGetCount

semGetCount ( )
Name: semGetCount ( ) - get semaphore count
Synopsis:
u32 semGetCount
(
  SEM_HANDLE semHandle /* semaphore to get the count of */
)
Description: Returns the current count of the semaphore.
Include: sempaphore.h
Returns: The current count of the semaphore.
See Also: semTake semGive


 


© 2001-2002 Navosha, Inc.