SEMMGR is a program which manages multiple system semaphores on your behalf.
SEMMGR is a detached program with which BE communicates to manage system semaphores. SEMMGR can only be run as a detached task. If you try to run it from the command line SEMMGR will report an error. If SEMMGR is not already loaded any one of the BE semaphore related commands will detach it. SEMMGR can be manually detached from the command line.
To do this, enter:
DETACH SEMMGRfrom the command line.
SEMMGR creates, clears, sets, waits on and closes system semaphores. System semaphores are named objects which you may use for signalling or synchronisation between processes. The name always takes the form of:
\SEM\path\name.extwhere the path and extension (.ext) are optional. SEMMGR always uses semaphores of the form:
\SEM\SEMMGR\<name>where name is the semaphore name which you supply to the BE semaphore function. This has been done to minimise the chance of interfering with other system semaphores.
The traditional use of semaphores is to control access to a resource which may not have more than one user at a time. The resource may not have more than one user because it could be damaged or behave unpredictably. For example, you would not want more than one process to access the same serial port at the same time. A semaphore can be created to represent the resource. Other processes should not access the resource unless they "own" the corresponding semaphore. Owning a semaphore is represented by setting the semaphore. When a semaphore is not owned by any one, it should be set to clear. A process should wait for a semaphore to become clear. It should then set the semaphore and continue processing.
The BE program supplies several sub functions which help you manage semaphores via SEMMGR.
Consider the following situation:
Several processes are all waiting for the same semaphore to clear. The process which owns the semaphore finishes and clears the semaphore. All of the waiting tasks find that the semaphore is clear. They all then set it, thinking that they own it, and they all then proceed to run the same resource critical task simultaneously. There can be some time between when the process finds that the semaphore is clear and when it actually sets it. To overcome this problem, SEMSET waits until semaphore is clear before it sets it and returns control back to BE.
To illustrate the use of semaphore usage, the following files have been provided.
DETACH SEMMGRThis is how SEMMGR can be manually detached to run as a background process. If SEMMGR has not been detached and BE needs to process semaphore functions, BE will detach it for you.