The lock method determines
whether the mutex is free and reacts accordingly:
- If the mutex if free, this operation locks it and
allows the calling task to enter its critical section.
- If the mutex is already locked, this operation
places the calling task on a waiting queue with other blocked tasks.
In environments other than pSOSystem, this
is a macro that implements the same interface.
SignatureRiCOSResult RiCOSMutex_lock (RiCOSMutex *const me);
Parametersme
The RiCOSMutex object
to lock
ReturnsThe RiCOSResult object,
as defined in the RiCOS*.h files
ExampleRiCOSResult RiCOSMutex_lock(RiCOSMutex * const me)
{
if (me == NULL) {return 0;}
if (semTake(me->hMutex, WAIT_FOREVER)==OK) {
return 1;
}
else
return 0;
}