BuildForge Help

Semaphores

Semaphores are global signal flags in the system that set up mutually exclusive (mutex) resources. Use them to make some processes wait for other processes to finish.

Use Jobs > Semaphores to view job semaphores that are in use. You can also clear semaphores, which may be necessary when a hung or cancelled job fails to release its semaphore.

You implement semaphores through a pair of dot commands: the .semget and .semput commands. Use the .semget command to "grab" a label: after a step gets a label, any other steps (in any project) that try to get the same label must wait until the original requester releases it.
Note: A step that contains a .semget command waits until the semaphore is released. If a job fails and leaves its semaphore active, the semaphore must be cleared manually before any job that uses the semaphore can run again.

For example, suppose you have a program that creates a printer driver, and you want the program to be used by only one process at any one time. Within each project that calls the program, set up three steps with the following command lines:

Step

Command Line

Get semaphore

.semget $BF_PROJECTNAME_PHYS

Execute driver creator

printdrivermaker.exe windows

Release semaphore

.semput $BF_PROJECTNAME_PHYS

You can establish semaphores for key resources in your organization, such as a heavily loaded server or a software program with a single-user license. Every step that uses the resource you want to protect should be wrapped with .semget and .semput commands.

Semaphores obey the following rules: