BOLT (FB)

FUNCTION_BLOCK FINAL BOLT

This function block gives exclusive or simultaneous access to a critical section. It is based on the runtime system function SysCpuTestAndSet. Exclusive access is only possible after all simultaneous accesses have been ended. As long as there is an exclusive access, the simultaneous access calls are rejected. Simultaneous accesses are initiated with the method Enter. This means the number of accesses in the critical section is increased by one. The method Leave is required to leave the critical section. It reduces the number of accesses in the critical section by one. Exclusive access is requested with the method Reserve . This call can only be successful if the number of accesses in the critical section equals zero. If this is not the case, all new calls of the method Enter are denied to make sure the number of accesses is not increased further. If all those who previously accessed the critical section have left with the method Leave, the next call of the method Reserve will be successful. The critical section can now be accessed exclusively. When all work is done, the section has to be returned with the method Free. If exclusive access has already been granted, calls for simultaneous access are denied. Further calls for exclusive access are also denied but they are counted. The calls for simultaneous access are successful as soon as all exclusive accesses have been ended. If the method was executed successfully, TRUE is returned, else FALSE is returned. A critical section may only be accessed if the methods Enter or Reserve have returned TRUE.