0

I am reading Chap9 of Operating System Concepts and the concept of pure demand paging is described as follows:

In the extreme case, we can start executing a process with no pages in memory. When the operating system sets the instruction pointer to the first instruction of the process, which is on a non-memory-resident page, the process immediately faults for the page....

But if NONE of the pages, particularly the pages containing code, are in memory, how does the OS know where the program counter is in the first place? Is program counter set as part of process creation by inspecting the program image on disk? If so, I would assume the OS knows the format of the binary image and can directly access that info on disk. And it will only make sense if somehow this info is stored in the part of the program image not needed during program execution, if OS decides not to bring the page containing this info into memory.

To summarize, I would like to know:

  • How is program counter set for a new process if using pure demand paging?
  • Is any real OS using pure demand paging and what benefit does it have?
  • How does an executable's binary format (e.g. ELF, PE formats) help the OS do demand paging (OS needs to know where the first page is at least?)
Rich
  • 1,669
  • 2
  • 19
  • 32
  • See [Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) and [Peering Inside the PE: A Tour of the Win32 Portable Executable File Format](https://msdn.microsoft.com/en-us/library/ms809762.aspx) – xmojmr Jul 03 '17 at 10:01
  • 1
    OS can map a shared read-only loader in the address space of each process at a fix address and set the program counter to the first instruction of the loader. – Yogi Jul 10 '17 at 12:19

0 Answers0