4 ms·
> I'm not sure if I really want to implement demand paging Yes, you probably should. It's the quintessential example of using virtual memory and handling page
by exDM69 10y ago
> I'm not sure if I really want to implement demand paging
Yes, you probably should. It's the quintessential example of using virtual memory and handling page faults so you probably want to do it just for the educational value (although that would need a disk driver too).
But it's also the key to implementing various modern operating system tricks, such as memory mapped files and dynamically expanding (and contracting) stack (for userspace processes, kernels typically don't do this AFAIK).
What you probably do not want to do is old-fashioned swap space on disk. It's not as useful as it once was because we have A LOT of memory these days and it might be harmful for SSD wear. For implementing this, you'd also need to have some kind of LRU cache to figure out which pages can be swapped out (quite typically in applications like this, swapping in is the easy part, figuring out what to swap out is more difficult).
- phil-opp 10y ago> What you probably do not want to do is old-fashioned swap space on disk Yeah, that's what I meant. I definitely plan to use the various lazy loading tricks for mmaped files, loading executables, etc. But first we need a disk driver :D.
- Animats 10y agoOne advantage of not supporting paging is that it gets the disk driver and file system out of the kernel. They're not needed early. You need a boot loader that can load the OS and process images, so the OS starts with some processes running. The disk driver (if any) comes in that way, rather than as part of the kernel. QNX works like this. It's convenient for embedded systems, where you may have no disk at all, ROM, flash, or a hard disk.