Home > Software engineering >  Difference between aliased (ALI) and shared (SHM) memory on MacOS
Difference between aliased (ALI) and shared (SHM) memory on MacOS

Time:12-12

I am using vmmap on MacOS. For one region it shows that sharing mode = aliased (ALI):

REGION TYPE     START - END       [ VSIZE  RSDNT  DIRTY   SWAP] PRT/MAX SHRMOD PURGE    REGION DETAIL
mapped file  1008dc000-1008e0000  [   16K    16K    16K     0K] rw-/rwx SM=ALI          /Users/USER/*/data

I wasn't able to find any information what does that mean. This page states that

Aliased (ALI) and shared (SHM) memory are shared between processes.

There is no further information about the difference between ALI and SHM. Can you help me understand what the difference is?

CodePudding user response:

When the memory is shared (SHM) both processes can access is simultaneously.

However, when the memory is aliased (ALI) only one process at the time has the virtual address mapped to the physical memory. When second process tries accessing memory, these steps happen:

  1. Process 2 gets page fault.
  2. Kernel unmaps memory from the Process 1.
  3. Kernel maps the memory to the Process 2.
  4. Now, the process 2 can write/read from the memory.

This is different to how the memory works on linux where there is no aliased (ALI) mode, only shared.

Source.

  • Related