Had some free time recently so I made a visual explainer on how shared memory actually works in Linux.
Normally, two processes have completely separate virtual address spaces. Process A shouldn't be able to touch Process B's memory at all.
But with shared memory, one process can write a value and another process can read it without copying the payload between them.
The video goes through virtual memory, page tables, physical frames,
shm_open, ftruncate, mmap with MAP_SHARED, lazy allocation, and what actually happens when either process touches the mapping.I also get into related mechanisms like memory-mapped files, shared libraries, copy-on-write after
fork(), zero-copy IPC, and eventually Dirty COW and what can happen when these page-table tricks go wrong.Link for anyone interested
Feedback welcome :)
https://redd.it/1vjrahk
@r_linux