Example :
Unix kernel parameters:
SEMMNI = 100 # semaphore identifiers
SEMMSL = 50 # max semaphores per id or set
SEMMNS = 500 # semaphores in system
Oracle parameter:
PROCESSES=150
If the maximum number of semaphores in a set is less than (processes+4), Oracle will try to allocate at most (processes+4)/2 semaphores per set, even less if that's still too large.
Basically, the server tries to allocate a set of processes+4 semaphores, and if this fails, it divides the number by 2 and tries again, until it succeeds, and that's the number per set it will use.
Next, it subtracts 4 from this number (for internal use) and the remainder is what can be used for process semaphores.
So processes+4 makes 154 divided by 2 makes 77.
77 > 50 so we need to divide it again by 2 which makes 38 which is < 50 so 38 is OK.
Next, we substract 4 from this number (for internal use) which makes 34.
Now, we need 150 semaphores, this makes 5 sets of 34 semaphores each.
(5 sets makes 170, 4 sets is not enough because it only makes 136 < 150)
At the end we do not need sets of 34 but 38 (34 + 4) which makes 5 sets of 38.
With the above settings, Oracle will create 5 sets of 38 semaphores each
With the above settings, Oracle will create 5 sets of 38 semaphores each