Chapter 5: Locking and Interprocess Communication
q_messages
q_receivers
q_sendersstruct msg_receiverstruct task_struct
ipcs_idr struct msg_msgstruct msg_queuestruct
kern_ipc_permID to pointer mappingstruct
ipc_idsFigure 5-6: Data structures for System V message queues.5.3.4 Shared Memory
From the user and kernel perspective,shared memory— the third and final SysV concept for interprocess
communication — uses similar structures for its implementation to the first two mechanisms described
above. Its essential aspects do not differ from those of semaphores and message queues.❑ Applications request an IPC object that can be accessed via a common magic number and a
kernel-internal identifier via the current namespace.
❑ Access to memory can be restricted by means of a system of privileges.
❑ System calls are used to allocate memory that is associated with the IPC object and that can be
accessed by all processes with the appropriate authorization.Kernel-side implementation also adopts very similar concepts to those described above. I will therefore
make do with a brief description of the data structures shown in Figure 5-7.shm_fileshmid_kernel struct
address_
spacestruct
fileipcs_idrID to pointer mappingstruct
ipc_ids kern_ipc_permFigure 5-7: Data structures for System V shared memory.Once again, a combination ofkern_ipc_permandshmid_kernelheld in theentriesarray of thesmd_ids
global variable is used to facilitate management of the access permissions to the IPC object. A dummy