SEMIDSTATE
(Statement)
[RC7 Version 2.2 or later]

Returns the current status (enabled or disabled) of the specified semaphore ID.

SEMIDSTATE (<SemaphoreID>)

This function returns the enabled (1) or disabled (0) status of the specified semaphore ID. Executing CREATESEM enables a semaphore ID and executing DELETESEM disables it.

Create a semaphore to be used in PRO1 and PRO2, as a supervisory task TSR1, only when the SEMIDSTATE returns the disabled status of the specified semaphore ID.
'!TITLE "Create semaphore"
|
|
PROGRAM TSR1
|
|
FOLDER DEFINT SEMID
|
'Only when SEMID is not 1 (enabled), create a semaphore.
|
IF SEMIDSTATE (SEMID) <> 1
|
|
SEMID = CREATESEM (0)
|
|
ENDIF
|
|
END
|
|
|
|
'!TITLE "Semaphore control in writing to I0"
|
|
PROGRAM PRO1
|
|
EXTERN DEFINT SEMID
|
|
TAKESEM SEMID
|
|
I0=1
|
|
GIVESEM SEMID
|
|
END
|
|
|
|
'!TITLE "Semaphore control in writing to I0"
|
|
PROGRAM PRO2
|
|
EXTERN DEFINT SEMID
|
|
TAKESEM SEMID
|
|
I0=1
|
|
GIVESEM SEMID
|
|
END
|
|