Class OSMutex - DEPRECATED

Page date Thu Mar 10 10:20:04 2011 .   Improve this page

OSMutex

The mechanism implemented by this class is tested by the project mutexStress.

Constructors

OSMutex()

Description

Initialize the internal members.

Parameters

:* none

Methods

== int acquire(bool doNotBlock = false) == Description

Try to acquire mutex. If doNotBlock is false, the task is blocked (using eventWait) until this mutex is released, by other task.

Parameters

:* doNotBlock - input, if it is false, the task is blocked until this mutex is released

Return value

:* OK - ok, this mutex is successfully acquired

:* ERROR_EVENT- error, the event failed in waiting for this mutex to become available

:* ERROR_WOULD_BLOCK - error, the mutex is already acquired and noBlock is true

== int release(OSTask * pTask = 0) == Description

Release owned mutex.

Parameters

:* pTask - input, the task which should own the mutex

Return value

:* OK - ok, this mutex is successfully released

:* ERROR_NOT_OWNER - error, the pTask, input parameter, is not the task which acquired the mutex

:* ERROR_NOT_ACQUIRED - error, this mutex is not acquired

OSTask * getOwnerTask(void);

Description

Return the task owner of the mutex.

Parameters

:* none

Return value

:* the (pointer to) the task which owns the mutex

OSEvent_t getEvent(void);

Description

Return the event used for notification the acquire and release of the mutex.

Parameters

:* none

Return value

:* the event used for notification the acquire and release of the mutex

void setEvent(OSEvent_t event)

Description

Set the given event used for notification the acquire and release of the mutex.

Parameters

:* event - input, the event

Return value

:* none

OSEventWaitReturn_t getEventReturn(void)

Description

Return the event return value used for notification.

Parameters

:* none

Return value

:* the event return value used for notification

Variables

== static const int OS_OK = 1== == static const int OS_NOT_OWNER = -1== == static const int OS_NOT_ACQUIRED = -2== == static const int OS_OTHER_EVENT = -3 == == static const int OS_WOULD_BLOCK = -4== Description

All are used as result code for acquire and release methods.