> There is no sensible OS API that could support this, because fundamentally memory access is a hardware API.
there's nothing magic about demand paging, faulting is one way it can be handled
another could be that the OS could expose the present bit on the PTE to userland, and it has to check it itself, and linux already has asynchronous "please back this virtual address" APIs
> Memory operations are always synchronous because they’re performed directly as a consequence of CPU instructions.
although most CPU instructions may look synchronous they really aren't, the memory controller is quite sophisticated
> Fundamentally there aren’t any sensible ways to improve on this problem, because the problem only exists due to us pretending that our machines have vastly more memory than they actually do. Which comes with tradeoffs, such as having to pause the CPU and steal CPU time to maintain the illusion.
modern demand paging is one possible model that happens to be near universal amongst operating system today
there are many, many other architectures that are possible...
> although most CPU instructions may look synchronous they really aren't, the memory controller is quite sophisticated
I was eliding at lot of details. But my broader point is that from the perspective of the thread being interpreted, the paging process is completely synchronous. Sure advanced x86 CPU maybe be tracking data dependencies between instructions and actively reordering instructions to reduce the impact of the pipeline stalling caused by the page fault. But that’s all low level optimisation that are (or should be) completely invisible to the executing thread.
> there are many, many other architectures that are possible...
I would be curious to see any examples of those alternatives. Demand paging provides a powerful abstraction, and it’s not clear to me how you can sensibly move page management into applications. At a very minimum that would suggest that every programming language would need a memory management runtime capable to predicting possible memory reads ahead of time in a sensible fashion, and triggering its own paging logic.
there's nothing magic about demand paging, faulting is one way it can be handled
another could be that the OS could expose the present bit on the PTE to userland, and it has to check it itself, and linux already has asynchronous "please back this virtual address" APIs
> Memory operations are always synchronous because they’re performed directly as a consequence of CPU instructions.
although most CPU instructions may look synchronous they really aren't, the memory controller is quite sophisticated
> Fundamentally there aren’t any sensible ways to improve on this problem, because the problem only exists due to us pretending that our machines have vastly more memory than they actually do. Which comes with tradeoffs, such as having to pause the CPU and steal CPU time to maintain the illusion.
modern demand paging is one possible model that happens to be near universal amongst operating system today
there are many, many other architectures that are possible...