|Applies To||RSA ACE/Server|
|Issue||What are semaphores and what do they do?|
|Resolution||Semaphores are used to manage access to shared resources, kind of a traffic cop for processes. They are very important since simultaneous access to these resources can result in corrupted data. There are two types of semaphores, named and unnamed.|
Named semaphores are always present and typically initialized by the operating system. They are used to manage access to shared system resources such as files and memory. Many applications gain access to these resources and will use these semaphores. They are OS specific.
Unnamed semaphores are initialized by an application and will be killed when the application is closed. They are commonly used to manage inter-process communications. For instance, semaphores can be used to lock a shared resource from being used by a process that is dependent on another process being completed
The actual process of managing semaphores is simple in theory. The semaphore is given an integer value that represents the number of concurrent processes that can be locked by the semaphore. As processes request access to the resource, the semaphore is locked and decremented by 1. When the process is finished using the resource, the semaphore is unlocked and incremented by 1. If the semaphore count reaches 0 or a negative number, there are no semaphores available for that resource and the process must wait for a semaphore to free up. There are other methods for semaphore management, but the differences are pretty minor.
Problems can occur when unfriendly processes do not use the semaphore for the resource or do not free up the semaphore when done. All processes that share the resource must use the same semaphore for that resource, otherwise errors will likely occur.
For specific information on calculating semaphore values for the ACE/Server, try this Calculating kernel parameters for semaphores - what are the requirements when using Remote Administration sessions?.
|Legacy Article ID||a697|