Semaphore Parameters

team bbl


A semaphore is a counter and the operations associated with it. Semaphores provide a synchronized way for multiple processes to access a shared resource. Semaphores can be used as simple signals to synchronize processes, or as locks to prevent collisions on shared resources.

Linux includes several kernel parameters that are associated with semaphores. These parameters, based on a 32-bit Intel system, are summarized in Table 13-1.

Table 13-1. Kernel Parameters Associated with Semaphores

Name

Description

Default

Maximum

semmni

Maximum semaphore sets

128

2GB

semmsl

Maximum semaphores per semaphore set

250

65536

semmns

Maximum semaphores system-wide

32000

2GB

semopm

Maximum operations per semop system call

32

2GB

semvmx

Maximum semaphore value

32767

65536


Linux also defines other semaphore-related parameters that are not currently in use.

The following sections examine semaphore-related parameters in detail.

semmni

semmni sets the total number of semaphore sets that a system can have. At initialization time, the kernel creates an array of default semmni pointers, each of which points to a semaphore identifier structure. As a user tunes this parameter, the kernel adjusts the size of the semaphore ID array accordingly (to at most IPCMNI). Note that the hard limit of 2GB maximum value is derived from the kernel parameter's data type (int). Theoretically, you can have a maximum of 2GB semaphore sets in your system. In the Linux kernel, however, each semaphore identifier needs 44 bytes of kernel memory for the IPC identifier structure, plus 68 bytes for each semaphore set structure. Therefore, 2GB semaphore identifiers require at least (44+68)*2G=224GB of kernel memory. The recommended maximum is 32767.

semmns

semmns determines the maximum number of allowable semaphores system-wide. Because semmni is the maximum number of all possible semaphore sets, and semmsl is the maximum number of semaphores per set, the maximum total number of semaphores overall should not be greater than the product of semmni and semmsl. By default, semmns equals semmni*semmsl but is not calculated automatically.

semmsl

semmsl is the maximum number of semaphores allowed in a semaphore set. The default value is 250. The 65536 limit comes from the data type, unsigned short. In practice, semmsl should not be set to the upper limit in order to reduce the chance of a kernel memory allocation failure. The higher the number of semaphores in a semaphore set, the more kernel memory is required to save the undo operations. We recommend setting semmsl to 8000 to reduce memory pressure.

semopm

semopm defines how many operations a single semop() call can operate on a semaphore set. The semop() call checks the operation array size against this limit. We recommend setting semop() to 8000.

semvmx

semvmx sets the maximum value of a semaphore. The semvmx hard limit is 65536 because of its data type (unsigned short). semvms cannot be changed dynamically like the other four parameters; we recommend that you leave it as the default value of 32767.

Unused Semaphore Parameters in Linux

This section discusses the semaphore-related parameters defined in Linux but not currently in use in its IPC implementation. These parameters can be found in use in other UNIX-like operating systems, such as HP/UX or Solaris. It is worth mentioning that other semaphore-related parameters are defined in Linux, but are not currently in use. The /usr/include/linux/sem.h file defines the following unused parameters:

  • semume. The maximum number of undo operations per process. The semaphore undo operation is currently implemented in the Linux kernel, but there is no per-process limit on how many undo operations it can perform. The default value for semume equals semopm (32).

  • semmnu. The maximum number of undo operations system-wide. As with semume, Linux does not restrict how many semaphore undo operations can be performed in total. The default of semmnu is equivalent to the default of semmns (128).

  • semaem. The maximum count a semaphore can be adjusted if the associated process dies. The default is semvmx >>1 (8192).

  • semmap. The maximum number of entries in the semaphore map. Some operating systems preallocate memory for allocation and deallocation of the memory segments for semaphore identifiers, but this is not supported in the current Linux implementation The default value is semmns (32000).

  • semuse. Defines the size of the semaphore undo structure. Its value is 20 bytes.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net