Main Page   Modules   Data Structures   File List   Globals  

mutex.h File Reference

Header file for mutex.c. More...

#include "types.h"
#include "task.h"

Go to the source code of this file.

Data Structures

struct  OtosMutex

Defines

#define MUTEX_SUCCESS   0
#define MUTEX_ALREADY_LOCKED   1
#define MUTEX_TIMEOUT   2
#define MUTEX_NOT_OWNER   3

Functions

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

uint8_t otosUnlockMutex (OtosMutex *pMutex)
 Unlock a mutex.


Detailed Description

Header file for mutex.c.

Definition in file mutex.h.


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 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