Skyz wrote:
Is there a mode that it can be avoided, what's the benefit of running paging. I don't see any os using applications.
x86 protected mode doesn't use paging until it is explicitly enabled, so basic real mode and protected mode can both be used without paging.
But paging brings massive benefits:
- Simplifies process separation. With a page table per isolated address space, it is easy to control what memory is exclusively or shared mapped at a per-page per process level.
- Simplifies memory allocation. For a process logical address space, the allocated physical memory can be anywhere, it need not be contiguous. This is the basis of virtual memory, and is very difficult to do with segmentation, because contiguous virtual memory also has to be contiguous in physical memory using base/limit segmentation.
- Reduces memory usage. Because virtual memory pages can be unmapped, and mapped in on demand, not all memory a process needs has to be actually resident. Demand paging allocates memory to address spaces as it's needed, and a process rarely needs all its memory all of the time, so some can be discarded when not in use and (re-)read from disk as required.
Personally, I see paging and virtual memory management as considerably more useful and fundamental for operating systems than, for example, file systems. A minimal kernel needs to implement, if it is providing protected address spaces at all, a paging mechanism. The only systems that don't are simple embedded kernels, which provide essentially a threaded runtime to some dedicated application, which might not even have a MMU. Think IoT.
Otherwise, for a general purpose kernel, paging is fundamental, and no general purpose CPUs in common use (except x86) provide anything other than a page based MMU. Even single address space kernels benefit from paging if the CPU provides it.