Release 10.1A: OpenEdge Data Management:
Database Administration

> ## Semaphores

> On single-processor systems, semaphores are used to synchronize the activities of server and self-service client processes that are connected to a database. By default, each database has an array of semaphores, one for each user or server. Each process uses its semaphore when it must wait for a shared resource. Semaphores are not used for single-user sessions or for client sessions connecting to a remote database on a server system.

> Figure 13–12 shows how semaphores control access to shared resources.

> Figure 13–12: How a semaphore coordinates concurrent access

> When process 5 needs access to a record, index, or other shared resource already locked by process 8, process 5 decrements its semaphore. When the process holding the lock (process 8) releases the resource, it notifies the waiting process (process 5) by incrementing the semaphore.

> Semaphores are grouped into semaphore sets. Each semaphore set has a unique identifying number called a semid. Within a semaphore set, individual semaphores are identified by an integer ranging from 0 to one less than the size of the semaphore set.

> The OpenEdge broker preallocates semaphores when you start the database with PROSERVE. Each process requires one semaphore. The broker uses two additional semaphores internally. The database engine uses the following formula to determine the number of semaphores (#SEM) to allocate:

>     #SEM = Max-possible-users (-n) + Max-possible-servers (-Mn) + 4

> Table 13–2 lists the UNIX kernel parameters that control the number and size of the semaphore sets.

> Table 13–2: UNIX kernel parameters that affect semaphores
> Parameter | Description | Recommended setting
> `SEMMNI` | The maximum number of semaphore identifiers allowed for the system. | One per active multi-user database. If you set this value too low, the database engine might generate error 1131.
> `SEMMSL` | The maximum number of semaphores allowed per semaphore identifier (semaphore set). | (Max-local-users-on-any-databases + Max-#servers-on-any-databases + 4). If you set this value too low, the database engine might generate error 1093 or 1130.
> `SEMMNS` | Total number of semaphores allowed for the system. | `SEMMSL` * number of active databases. If you set this value too low, the database engine might generate error 1093, 1131, or 1195.
> `SEMMNU` | Maximum number of semaphore undo structures allowed for the system. | Same value as `SEMMNS`. If you set this value too low, the database engine might generate error 1081.

> When you install the OpenEdge RDBMS, you might have to increase the values of these parameters. If you are running other software that uses semaphores, take into account the combined requirements. See your system documentation for information on how to change these parameters.

> The amount of kernel memory required for semaphores is relatively small, so setting the limits higher than your current needs probably will not affect performance.

> The PROMON R&D Shared Resources option displays the number of semaphores used. When you start the broker process, a message specifies the number of semaphores still available. If the number of database users grows large, the database engine might exceed the maximum number of semaphores allowed, specified by the `SEMMNS` parameter. If this happens, you must reconfigure the system’s kernel to increase the semaphore limit. You can reduce semaphore use only by lowering the values of the Number of Users (-`n`) and/or Maximum Servers (-`Mn`) startup parameters.

> ##### Allocating semaphores

> By default, the database engine uses one semaphore set for all the semaphores needed by the database. When greater than 1000 users connect to a single database, there might be high contention for the semaphore set. Using multiple semaphore sets helps alleviate this contention and improve performance with high user counts. The broker startup parameter, Semaphore Sets (-`semsets`), allows you to change the number of semaphore sets available to the OpenEdge broker.

> The broker uses two groups of semaphores, Login and User. The Login semaphore is used during connection to the database. The system allocates one User semaphore for every user specified by the Number of Users (-`n`) startup parameter. User semaphores are allocated using a round robin mechanism. If you specify the number of Semaphore Sets, PROSERVE allocates one set for the Login semaphore and the remaining sets are used for User semaphores.

> In this example, the broker uses two semaphore sets, one for the Login semaphore and one for the ten User semaphores:

>      proserve db-name -semsets 2 -n 10

> In this example, the broker uses three semaphore sets, one for the Login semaphore, one for five of the User semaphores, and one for the remaining five User semaphores:

>     proserve db-name -semsets 3 -n 10

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095