The provision of paging of file content leads to the possibility of demand paging for programs, enabling them to be loaded into memory dynamically and to have only the active portions of those programs resident. To achieve this, programs must be appropriately initialised in new tasks, with a page fault handler configured to provide program file content whenever a region of the program payload is encountered that is not currently resident in memory.
To load and initialise a program, a new task must be created, defining a separate address space for the program and allowing it to operate independently of other programs. For a program to actually run, a thread of execution must be created so that the program's instructions can be read and processed.
When satisfying page faults for a task, one approach involves situating the page fault handler within the task itself, this managing the available memory regions and employing receive windows when requesting memory pages.
The general arrangement involving such internal page fault handlers for a program in a task is as follows:
Another approach is to employ an external page fault handler in the creating task. When a page fault occurs, the external handler ensures that the appropriate content has been brought into its own memory space. It then returns a flexpage from the handler routine to resolve the fault.
This arrangement may be used to support a program deployed in a task. Since an internal page fault handler is just another kind of program, this external pager arrangement can be constrained to only supporting an internal page fault handler deployed in a task.
To provide an internal page fault handler alongside an actual program to be run, the following arrangement is used:
The creating task performs the following operations:
Upon starting, the program will encounter a page fault immediately, unless some additional work was done to map memory pages into the task in advance. The internal pager or page fault handler will attempt to resolve these faults as they occur, being contacted by the kernel on the program's behalf.