Introduction
Previous Topic  Next Topic 

The Semaphore Library (CXSEM.DLL) provides semaphore functional to provide for critial sections within the code where it is necessary to ensure that only one task is accessing a particular data object or excecuting a particular set of code.


A semaphore is a special type of variable that can hold one of two values (set or unset) and can protect a section of code from being excecuted when another task has set the semaphore by providing functions that wait, check and set a semaphore and/or wait until a semphore is clear before allowing a process to enter the critical section.


The functions in this library rely on a fixed set of 1024 semaphores numbered 0 through to 1023.        Each function takes one of these semaphore IDs as a function argument.


Note that the functions in this library are sensitived to the kill signal.   If a task is killed (either by an expicit external task_kill() call, by exceuting a stop or restart statement or by chaining to another task) then any semaphores that have been set by the task will be cleared and it will be removed from any queues wiating for semaphores.