1.1 --- a/docs/wiki/Program_Loading Mon Sep 18 19:11:17 2023 +0200
1.2 +++ b/docs/wiki/Program_Loading Sat Dec 09 01:24:59 2023 +0100
1.3 @@ -15,7 +15,45 @@
1.4 separate address space for the program and allowing it to operate
1.5 independently of other programs. For a program to actually run, a thread of
1.6 execution must be created so that the program's instructions can be read and
1.7 -processed.
1.8 +processed. Once running, the program must be able to interact with the system
1.9 +environment and to have its memory resources made available to it upon demand.
1.10 +
1.11 +A number of elements must be prepared to be able to run a program, these being
1.12 +summarised below.
1.13 +
1.14 +=== Program Executable File ===
1.15 +
1.16 +The program executable file is obtained and the program metadata loaded,
1.17 +identifying the memory regions and entry point (the location of the first
1.18 +instruction).
1.19 +
1.20 +=== Task and Threads ===
1.21 +
1.22 +A new task is created to hold the program. For this new task, new threads are
1.23 +created to run and support the program. One thread will run the actual
1.24 +program, and another will be used as the region mapper to handle page fault
1.25 +conditions.
1.26 +
1.27 +=== Thread Resources ===
1.28 +
1.29 +Memory is allocated for the new program's threads, particularly the stack for
1.30 +each thread.
1.31 +
1.32 +Each stack is populated with program argument and environment information. Of
1.33 +particular importance are the capabilities to be made available to the threads
1.34 +since these permit interaction with the rest of the system.
1.35 +
1.36 +The capabilities to be used by the threads must be mapped into the new task.
1.37 +
1.38 +=== Thread Configuration ===
1.39 +
1.40 +To connect the main thread of the program to its region mapper, an IPC gate
1.41 +must be created. This is mapped to the new task where the region mapper will
1.42 +bind to it, using it to expose its interface.
1.43 +
1.44 +Thread properties such as pagers and exception handlers are defined for the
1.45 +threads, with the main thread employing the newly created IPC gate capability
1.46 +to delegate paging to the region mapper.
1.47
1.48 == Internal Page Fault Handlers ==
1.49