# HG changeset patch # User Paul Boddie # Date 1702081499 -3600 # Node ID 130727a2993db586551b7e6a9b9ba9178abdd959 # Parent f1fa7ed87b6ef9791568764c900c2ece91a23c98 Added a summary of the preparations required for initiating a program. diff -r f1fa7ed87b6e -r 130727a2993d docs/wiki/Program_Loading --- a/docs/wiki/Program_Loading Mon Sep 18 19:11:17 2023 +0200 +++ b/docs/wiki/Program_Loading Sat Dec 09 01:24:59 2023 +0100 @@ -15,7 +15,45 @@ 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. +processed. Once running, the program must be able to interact with the system +environment and to have its memory resources made available to it upon demand. + +A number of elements must be prepared to be able to run a program, these being +summarised below. + +=== Program Executable File === + +The program executable file is obtained and the program metadata loaded, +identifying the memory regions and entry point (the location of the first +instruction). + +=== Task and Threads === + +A new task is created to hold the program. For this new task, new threads are +created to run and support the program. One thread will run the actual +program, and another will be used as the region mapper to handle page fault +conditions. + +=== Thread Resources === + +Memory is allocated for the new program's threads, particularly the stack for +each thread. + +Each stack is populated with program argument and environment information. Of +particular importance are the capabilities to be made available to the threads +since these permit interaction with the rest of the system. + +The capabilities to be used by the threads must be mapped into the new task. + +=== Thread Configuration === + +To connect the main thread of the program to its region mapper, an IPC gate +must be created. This is mapped to the new task where the region mapper will +bind to it, using it to expose its interface. + +Thread properties such as pagers and exception handlers are defined for the +threads, with the main thread employing the newly created IPC gate capability +to delegate paging to the region mapper. == Internal Page Fault Handlers ==