System Architecture 2-43
Managing Shared-Memory Resources
Semaphores
When an OnLine user process attempts to acquire a latch and finds that the
latchis unavailable, the user process can block until the latch is available. The
mechanism that signals the process to wake when the latch becomes
available is a UNIX semaphore.
The semaphore mechanism works likes this. Every OnLine user process is
associated with a semaphore. If a user process finds a latch unavailable, the
semaphore associated with the process is placed on a list of waiting
semaphores.When the user process holding the latch is ready to release it, the
holding user process looks to see if any user processes are waiting for the
latch. If so, the holding process releases the latch and wakes the first appro-
priate user process in the semaphore list.
Ifthe latch to be released is a buffer latch, the holding user process wakes the
first waiting process that has a compatible lock access type. (Refer to
page 2-60 for further information about buffer acquisition.)
All semaphores are created when shared memory is created. In mostUNIX
operating systems, the number of semaphores permitted is equal to the
maximum number of concurrent user processes, specified asUSERS in the
OnLine configuration file.
UNIXkernel parameters can affect the number of semaphores created by your
UNIX operating system. (Refer to page 2-18 for a description of the role
played byUNIX kernel parameters.)
Forced Abort
If you explicitly kill a user process that is holding a latch, OnLine immedi-
atelyinitiates an abort to preserve data consistency.If an OnLine user process
is holding a latch, the implication is that the user process is intent on
modifying shared memory. When a user process terminates, thetbinit
daemoninitiates proper cleanup, releasing all locks and other resources held
by the user process.
Althoughtbundo can perform routine cleanup for processes that die prema-
turely, data consistency preventstbinit from releasing shared-memory
latchesas part of cleanup. It is impossible for tbinit to determine whether the
user process concluded its modifications before it was terminated or if the
database is in a consistent state.