|
ginnOS
The reference: libc, the libraries and the kernel
|
shared memory objects: pages that several processes map. More...
Go to the source code of this file.
Macros | |
| #define | SHM_MAX_SIZE (64u * 1024 * 1024) |
Functions | |
| kerr_t | shm_create (size_t size, struct file **out) |
| make a shared memory object of size bytes (rounded up to whole pages). | |
| bool | shm_is_file (const struct file *file) |
| true if the open file is a shared memory object (its mappings are VMA_SHARED areas). | |
shared memory objects: pages that several processes map.
shm_create makes an object of zeroed pages and an open file for it. a process maps it with mmap(fd); every mapping of the object, in any process, uses the same frames, so a write in one is seen in all. this is how a window's pixels go from an app to the compositor.
the object lives while its open file does (the file can be shared by fork and dup, and later sent over a socket). each mapping holds its own reference to the frames, so a mapping stays valid after the file is closed, and the frames are freed when the last file and the last mapping are gone.
| #define SHM_MAX_SIZE (64u * 1024 * 1024) |
make a shared memory object of size bytes (rounded up to whole pages).
| out | receives the open file (one reference), opened read-write. |