4 ms·
The original UNIX swap was literally just that. The entire process was written out to disk, and an entire process read back in. The early machines didn't have
by retrac 4y ago
The original UNIX swap was literally just that. The entire process was written out to disk, and an entire process read back in. The early machines didn't have enough RAM for more than one process and the kernel at the same time, anyway. A simple pair of relocation offset + limit registers suffice to enable memory protection, assuming privileged instructions trap. Paging is not required, though it certainly makes it all much more efficient.
Swapping to a file is non-trivial; many of the kernel structures and resources relating to files and userspace disk access are dynamically allocated; it's tricky to ensure you don't enter some low memory trap of death with not enough pages free to read in or out from the file system, and the only means to free them being through the file system. It's an edge concern even today you might run into if you try to swap to a FUSE filesystem.
- 95014_refugee 4y agoSwapping to blocks allocated to a file is relatively straightforward; people routinely overthink how hard this has to be. Existence proof: Mach / NextStep / Darwin (macOS/iOS/etc).