The Galvin OS text says that on older systems, there used to be a method, where the entire running process (when in idle state) was moved from the main memory (when main memory ran low) to the disk which acted as a backing store.
The text says that whatever processes we swap out are placed in the "swap space" of the disk.
Now as time passed the concept of swapping was used with paged processes as well:
Now I want to know when an executable is run where is the "process image" created and stored? In the picture below, the a.out
is executable and I know that the executable is just a binary containing the machine instructions and data and relocation information for the target machine. But the virtual memory of this executable is yet to be formed, or rather the "process" is different from executable, where there is specific: code, static/global variable section, heap section, and stack section.
The diagram below shows that "new process" having 4 pages is in the disk, but wherein the disk is it kept? Under file system or the swap space?
In the demand paging section the text says:
Now the above picture is concerning demand paging. Where in the disk are the pages A, B, C, D, E, F, G, H are placed is it in the swap space or in the file system? Is it so that the system uses swap space only for those dirty pages which are flushed out of the main memory, (while keeping the actual pages of the process under file system) and read them later subsequently, but if that is the case we could as such just switch off the swap space and work with the file system version of the process on disk. I was having this doubt because the text in a section says :
In Solaris 1 (SunOS), the designers changed standard UNIX methods to improve efficiency and reflect technological developments. When a process executes, text-segment pages containing code are brought in from the file system, accessed in main memory, and thrown away if selected for page out. It is more efficient to reread a page from the file system than to write it to swap space and then reread it from there. Swap space is only used as a backing store for pages of anonymous memory (memory not backed by any file), which includes memory allocated for the stack, heap, and uninitialized data of a process.
This is how the text defines virtual memory and demand paging:
Virtual memory involves the separation of logical memory as perceived by developers from physical memory. This separation allows an extremely large virtual memory to be provided for programmers when only a smaller physical memory is available. Virtual memory makes the task of programming much easier, because the programmer no longer needs to worry about the amount of physical memory available; she can concentrate instead on programming the problem that is to be solved. The virtual address space of a process refers to the logical (or virtual) view of how a process is stored in memory. Typically, this view is that a process begins at a certain logical address—say, address 0 - and exists in contiguous memory. In fact, physical memory is organized in page frames, and that the physical page frames assigned to a process may not be contiguous. It is up to the memory-management unit (MMU) to map logical pages to physical page frames in memory.
The demand paging and is commonly used in virtual memory systems. With demand-paged virtual memory, pages are loaded only when they are demanded during program execution. Pages that are never accessed are thus never loaded into physical memory. A demand-paging system is similar to a paging system with swapping where processes reside in secondary memory (usually an HDD or NVM device).