7
votes

By going through the manual pages of shmget(), I understand that shmget() invocation allocates # of pages in memory, which can be shared across processes.

Is it going to create kernel memory pages, which are mapped to the process's local address space? Or is the same process memory page reserved for this segment and the same will be shared for other attached processes as well?

My assumption:

  • When shmget() is called, the kernel is going to reserve some number of segments/pages.
  • When shmat() is called, the reserved segment is mapped to the process's address space/page.
  • When a new process attaches to the same segment, the kernel segment created earlier is mapped to the new process's address space.

Is this correct?

1

1 Answers

1
votes

The idea is more or less correct, except the wording "kernel memory page". The memory that is reserved/allocated in the memory-management is not specially made for the kernel. It is just "memory page", not mapped into the process memory yet.