5.3.3.4.4semctl()

A function that is invoked to set attributes, query status, or delete a semaphore. A semaphore is not deleted until the process waiting for a semaphore has received it. DAC is performed by invoking the ipcperms() function.

5.3.3.5Shared memory regions

Shared memory regions allow two or more processes to access common data by placing the processes in an IPC shared memory region. Each process that wants to access the data in an IPC shared memory region adds to its address space a new memory region, which maps the page frames associated with the IPC shared memory region. Shared memory regions are implemented in the kernel using the shmid_kernel data structure, and the shmat(), shmdt(), shmget() and shmctl() functions.

5.3.3.5.1shmid_kernel

Describes the structure and state information of a shared memory region with fields including shm_perm, which stores credentials in the kern_ipc_perm data structure; shm_file, which is the special file of the segment; shm_nattach, which holds the number of current attaches; and, shm_segsz, which is set to the size of the segment.

5.3.3.5.2shmget()

A function that is invoked to create a new shared memory region or to get a descriptor of an existing shared memory region based on a key. A newly created shared memory segment’s credentials are initialized from the creating process’s credentials. shmget() invokes newseg() to initialize the shared memory region. newseg() invokes shmem_file_setup() to set up the shm_file field of the shared memory region. shmem_file_setup() calls get_empty_filp() to allocate a new file pointer, and explicitly zeroes it out to ensure that the file pointer does not contain any residual data.

5.3.3.5.3shmat()

A process invokes shmat() to attach a shared memory region to its address space. DAC is are performed by invoking the ipcperms() function.

The pages are added to a process with the demand paging technique described in Section 5.5.2.5.6. Hence, the pages are dummy pages. The function adds a new memory region to the address space of the process, but actual memory pages are not allocated until the process tries to access the new address for a write operation. When the memory pages are allocated, they are explicitly zeroed out, satisfying the object reuse requirement, as described in Section 5.5.2.5.6.

5.3.3.5.4shmdt()

A process invokes shmdt() to detach a shared memory region from its address space. DAC is performed by invoking the ipcperms() function.

5.3.3.5.5shmctl()

A function that is invoked to set attributes, query status, or delete a shared memory region. A shared memory segment is not deleted until the last process detaches it. DAC is performed by invoking the ipcperms() function.

67

Page 79
Image 79
IBM 10 SP1 EAL4 manual Shared memory regions