Implementing System Calls

All operations on semaphores are performed using a single system call named ipc. This call is used not only for semaphores but also to manipulate message queues and shared memory. Its first parameter delegates the actual multiplex work to other functions. These functions are as follows for semaphores:

semctl performs a semaphore operation and is implemented in sys_semctl.

□ semget reads the semaphore identifier; sys_semget is the associated implementation.

□ semop and semtimedop are responsible for incrementing and decrementing the semaphore value; the latter enables a time-out to be specified.

The use of a single system call to delegate work to multiple other functions is a relic of early days.10 Some architectures to which the kernel was later ported (e.g., IA-64 and AMD64) dispense with the implementation of the ipc multiplexer and use the above "subfunctions" directly as system calls. Older architectures like IA-32 still provide the multiplexer, but individual system calls for the variants have been added during the development of kernel 2.5. Since the implementation is generic, all architectures benefit from this. sys_semtimedop offers the functionality of sys_ipc for SEMOP and SEMTIMEDOP, and sys_semctl and sys_semget are direct implementations of SEMCTL and SEMGET, respectively.

Notice that the operations that get an IPC object are, however, quickly reunited, as Figure 5-3 illustrates. This is possible because the data structures to manage IPC objects are generic and not dependent on a particular IPC type as described above.


10The kernel comment ''This is really horribly ugly'' for sys_ipc does have a cause.


10The kernel comment ''This is really horribly ugly'' for sys_ipc does have a cause.

Continue reading here: Ipcutilc

Was this article helpful?

0 0