Semaphores are a shareable resource that take on a non-negative integer value. They are manipulated by the P (wait) and V (signal) functions, which decrement and increment the semaphore, respectively. When a process needs a resource, a “wait” is issued and the semaphore is decremented. When the semaphore contains a value of zero, the resources are not available and the calling process spins or blocks (as appropriate) until resources are available. When a process releases a resource controlled by a semaphore, it increments the semaphore and the waiting processes are notified.
The Semaphore Kernel parameters
|maximum number of semaphores per array
|maximum semaphores system-wide
|maximum operations per semop call
Display them ?
This command displays the value of the semaphore parameters:
# /sbin/sysctl -a | grep sem
Calculate them ?
- Calculate the minimum total semaphore requirements using the following formula:
sum (process parameters of all database instances on the system) + system and other application requirements
- Set semmns (total semaphores systemwide) to this total.
- Set semmsl (semaphores per set) to 256.
- Set semmni (total semaphores sets) to semmns / semmsl rounded up to the nearest multiple of 1024.
The following formula can be used as a guide, although in practice, SEMMNS and SEMMNU can be much less than SEMMNI * SEMMSL because not every program in the system needs semaphores.
Set them ?
In the file, /etc/sysctl.conf
kernel.sem = 2200 6400 200 25
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
Then reboot or run this command:
# /sbin/sysctl -p