SEMAΒΆ

Provided by standard.lib.

A Software Semaphore (Interruptible)

BUSY = SEMA(CLAIM, RELEASE) means:

BUSY := X;

IF CLAIM THEN X:=TRUE;

ELSE IF RELEASE THEN BUSY := FALSE; X:= FALSE;

END_IF

X is an internal BOOL variable that is FALSE when it is initialized.

The input variables CLAIM and RELEASE as well as the output variable BUSY are type BOOL.

If BUSY is TRUE when SEMA is called up, this means that a value has already been assigned to SEMA (SEMA was called up with CLAIM = TRUE). If BUSY is FALSE, SEMA has not yet been called up or it has been released (called up with RELEASE = TRUE).

Declaration example

SEMAInst : SEMA ;

Example in IL

CAL SEMAInst(CLAIM:=VarBOOL1,RELEASE:=VarBOOL2)

LD SEMAInst.BUSY

ST VarBOOL3

Example in FBD

../_images/ef2433dc0674cc5d0a317f346d2b494e

Example in ST

SEMAInst(CLAIM:= VarBOOL1 , RELEASE:=VarBOOL2 );

VarBOOL3 := SEMAInst.BUSY;