lib/sema.txt
author Edouard Tisserant
Fri, 22 Jul 2022 09:24:12 +0200
changeset 1099 cdb045e8be20
parent 251 5e7457efbb8f
permissions -rw-r--r--
In VARIABLES.CSV, RETAIN variable were only flagged as such for GLOBALS, now local POU variable shoud be as well.
(*
 * (c) 2011 Edouard Tisserant
 *
 * Fake semaphore support, for non preemptive implementation.
 *
 *)


FUNCTION_BLOCK SEMA
  VAR_INPUT
    CLAIM : BOOL;
    RELEASE : BOOL;
  END_VAR
  VAR_OUTPUT
    BUSY : BOOL;
  END_VAR
  VAR
    Q_INTERNAL : BOOL;
  END_VAR

  Q_INTERNAL := CLAIM OR ( Q_INTERNAL AND (NOT RELEASE));
  BUSY := Q_INTERNAL;

END_FUNCTION_BLOCK