Main Page   Modules   Data Structures   File List   Globals  

Mutex Handling


Functions

uint8_t otosTestAndSet (uint8_t *pLock)
 Test and set a lock (integer variable).

uint8_t otosLockMutex (OtosMutex *pMutex, uint32_t timeout)
 Lock a mutex.

uint8_t otosUnlockMutex (OtosMutex *pMutex)
 Unlock a mutex.


Detailed Description

Mutex Handling

Function Documentation

uint8_t otosLockMutex OtosMutex *    pMutex,
uint32_t    timeout
 

Lock a mutex.

If the mutex is already locked, the task gets blocked. It is woken up again when the mutex is unlocked by another task.

Parameters:
pMutex Pointer to mutex
timeout Number of otOS timer ticks to wait for the mutex
  • 0: Don't wait, return immediately with status MUTEX_SUCCESS or MUTEX_ALREADY_LOCKED
  • INFINITE: Wait infinitely
  • else: Wait number of ticks
Returns:
  • MUTEX_SUCCESS: Mutex was locked successfully
  • MUTEX_ALREADY_LOCKED: Mutex was already locked
  • MUTEX_TIMEOUT: Timeout while waiting for mutex

Definition at line 104 of file mutex.c.

References g_pRunningTask, otosBlock, and otosTestAndSet().

uint8_t otosTestAndSet uint8_t *    pLock
 

Test and set a lock (integer variable).

A lock is either locked (1) or unlocked (0).

Parameters:
pLock Pointer to lock
Returns:
The old state of the lock.
  • 0: The lock could be locked.
  • 1: The lock was already locked.

Definition at line 66 of file mutex.c.

Referenced by otosLockMutex().

uint8_t otosUnlockMutex OtosMutex *    pMutex
 

Unlock a mutex.

If a task waits for this mutex, it is woken up.

Parameters:
pMutex Pointer to mutex
Returns:
  • MUTEX_SUCCESS: Mutex was unlocked.
  • MUTEX_NOT_OWNER: Running task doesn't own this mutex, so it cannot unlock it.

Definition at line 161 of file mutex.c.

References g_pBlockedQueue, g_performDispatch, g_pRunningTask, otosScheduler(), and otosWakeup().


Generated on Sat Jan 25 18:41:43 2003 for otOS by doxygen1.3-rc2