4 ms·
They mention: "the 'linear' idea of address space enshrined in Unix: Memory is assigned to the next free block of appropriate size (...) You end up with lots o
by illys 8y ago
They mention: "the 'linear' idea of address space enshrined in Unix: Memory is assigned to the next free block of appropriate size (...) You end up with lots of little pools of memory."
They probably refer to a 386+ way to manage memory - pagination - that allows to do much better.
The OS considers memory as a number of (originally 4kB) pages, some occupied, some others free. When you need a larger chunk of free memory, the OS organizes a set of pages to assemble a segment of memory. The application sees a regular linear memory, but the OS is not left with pieces of unrelated small memory spaces: the OS keeps a directory of free pages that can be used in any order to create the next "any size" linear block.
When the free page stock is exhausted, the OS keeps statistics of the least critical pages and unloads them to disk (OS code for unload destination, but it is the processor that provides the triggers), generating free memory pages.
The ghost pages are marked as occupied in the segment description, but unavailable (no RAM behind). When a program calls such a page, a processor exception calls an OS routine that reloads the missing page to a free page and connects it to the "linear" memory segment, as seen by the program. Then program execution is resumed.
The identification of the least critical pages is a major element in OS performance, since the unload/reload mechanism makes memory access work at hard disk speed :-( [Off-topic: pagination/segmentation are great, but I am more caution about the swapping mechanism, as it has made programmers very lazy in memory management, and previous computer generation very slow, mostly during the 1990s and 2000s - when memory was so expensive.]
Keywords if you like to know more: LDT, GDT, Descriptor Table, segmentation, pagination...
- p_l 8y agoclassic Unix memory management is based about "break pointers" which describe highest address of data segment, and a top of stack pointer, which limits the stack segment. Those areas are linear and you can't free a part in the middle. This is a historical curiosity from PDP-11 before the advent of paging, but apparently still used by some malloc() implementations. Modern memory management doesn't use linear mapping but instead uses paging to create chunks of accessible memory. Some applications still use a big linear address space by appropriately asking the OS then interoperating with memory management to only request the memory that is needed