The mxStatus function will return the status on the specified MUTEX variable.
Input:
mx : MUTEX
The mutex to query the status on.
Returns: INT
0
|
Mutex is unlocked.
|
1
|
Mutex is not initialized.
|
2
|
Mutex is locked.
|
Declaration:
FUNCTION mxStatus : INT;
VAR_INPUT
mx : MUTEX;
END_VAR;
Example:
INCLUDE rtcu.inc
THREAD_BLOCK Thread;
VAR_INPUT
mx : MUTEX;
...
END_VAR;
...
WHILE mxStatus(mx:=mx) <> 1 DO
...
END_WHILE;
END_THREAD_BLOCK;
PROGRAM MutexTest;
VAR
mx : MUTEX;
th : ARRAY[1..3] OF Thread;
i : INT;
...
END_VAR;
mx := mxInit();
IF mxStatus(mx:=mx) = 1 THEN DebugMsg(message:="mxCnt failed to init!"); END_IF;
FOR i := 1 TO 3 DO th[i](mx:=mx,...); END_FOR;
...
BEGIN
...
IF mxStatus(mx:=mx) <> 1 THEN
...
END_IF;
...
IF ... THEN
WHILE mxDestroy(mx:=mx) = 2 DO END_WHILE;
END_IF;
...
END;
END_PROGRAM;
|