lib/sema.txt
author Mario de Sousa <msousa@fe.up.pt>
Thu, 16 Feb 2012 10:27:52 +0000
changeset 443 ff4d26b7e51d
parent 251 5e7457efbb8f
permissions -rw-r--r--
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
(*
 * (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