A couple of common functions are used in all routines. They are defined in the ipc.h header file.
For each of these facilities, a header structure is maintained for each item allocated. This identifies the allowed operations with a permissions structure and provides parameters indicating the size, number of semaphores, or pending messages. These structures are all allocated from a pool, an array of structures whose size is determined by the tunable parameters. The identifier value returned to the user is used to produce an index into this array by taking this ID modulo the number of structures. This allows you to identify the appropriate header structure, given the ID number. This is distinct from the key , which contains a unique identifying code to be used by a process or group of processes to keep their data straight. This value is passed in when creating or locating some IPC facility; the ID value is like a file descriptor, which the user program uses to find the appropriate structures quickly. |