SEMA (FB)ΒΆ
FUNCTION_BLOCK FINAL SEMA
This function block realizes a counting semaphore.
It is based on the runtime system function SysCpuTestAndSet
.
A function block of type SEMA
is used to manage limited resources.
The counter of the semaphore symbolizes the number of resources available.
If there is no special parameterization, the semaphore counter has the value one.
The resources assigned to the semaphore are accessed with the Request
method.
This works as long as the counter is not zero at the time of the Request
call. The counter is then reduced by one.
With the method Release
the resource previously called is released and the counter is increased by one.
The call of the method Preset
adjusts the initial counter of the semaphore in accordance with the requirements.
If the method was executed successfully TRUE is returned, else FALSE is returned. A resource may thus only be used if the call Request
returns TRUE.
- InOut:
Scope
Name
Type
Initial
Input Const
ctPreset
1
Properties:
Methods:
Structure: