« Back to Product



 boolean IPS_SemaphoreEnter (string $Name, int $WaitingTime) 



Name that describes the semaphore


Milliseconds to wait until the command terminates


TRUE if the semaphore was entered. FALSE if the semaphore before the expiration of the waiting period could not be accessed.


This command sets a Semaphore (a sign with signal effect), which can be used to prevent the start of other scripts. A script can protect itself against any other competing scripts, and of course in front of other instances of itself.

In IP Symcon basically multiple scripts can run simultaneously. As long as the script does not require exclusive access to variables or system resources, this case presents no problem. If exclusive access is imperative a semaphore with that command can be set. The command first checks if the semaphore is set with the specified name. If it does not exist, it is set by the command and returns TRUE as feedback. All other scripts that try to put the same semaphore then have to go through a waiting period of the WaitingTime. After the waiting period, the command tries again to set the semaphore. If the attempt is successful, TRUE is returned otherwise FALSE.
If you want to ensure that during the execution of the script, the data it uses are not distorted by other, concurrently running scripts, you can use this command in order to secure exclusive access.

When using this command, it is vital to reset the semaphore via IPS_SemaphoreLeave after leaving the critical part.


if (IPS_SemaphoreEnter("CriticalPoint", 1000)) 
    // ...Run critical Commands

    //Release semaphore again!
    // ...No execution possible. Another script uses the "CriticalPoint" 
    // for more than 1 second, so our wait time is exceeded.
Any questions?