1.1 --- a/libexec/lib/src/process_creating.cc Sun Feb 26 22:19:31 2023 +0100
1.2 +++ b/libexec/lib/src/process_creating.cc Mon Feb 27 14:46:13 2023 +0100
1.3 @@ -21,15 +21,12 @@
1.4
1.5 #include <l4/re/env.h>
1.6
1.7 +#include <fsserver/resource_server.h>
1.8 #include <ipc/cap_alloc.h>
1.9 #include <ipc/map.h>
1.10
1.11 #include <stdio.h>
1.12
1.13 -#include <pthread-l4.h>
1.14 -#include <pthread.h>
1.15 -
1.16 -#include "parent_pager_object_server.h"
1.17 #include "process_creating.h"
1.18
1.19
1.20 @@ -49,26 +46,6 @@
1.21 {
1.22 }
1.23
1.24 -/* Start the system pager in a separate thread. */
1.25 -
1.26 -long ProcessCreating::start_pager()
1.27 -{
1.28 - pthread_t pager_thread;
1.29 - pthread_attr_t attr;
1.30 -
1.31 - pthread_attr_init(&attr);
1.32 - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
1.33 -
1.34 - ipc_server_init_for(&_config, ParentPagerObject, _exec_pager);
1.35 -
1.36 - long err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &_config);
1.37 -
1.38 - if (err)
1.39 - return err;
1.40 -
1.41 - return ipc_server_start_config_thread(&_config, pthread_l4_cap(pager_thread));
1.42 -}
1.43 -
1.44 /* Initialise the memory segments of the region mapper. These are mapped into
1.45 this task so that we may access them, allowing the external pager in this
1.46 task to use them. */
1.47 @@ -102,7 +79,7 @@
1.48 constrained to an area of memory that must not overlap with the area reserved
1.49 for the program being run. */
1.50
1.51 -long ProcessCreating::init_external_pager()
1.52 +long ProcessCreating::init_external_pager(l4_cap_idx_t *pager)
1.53 {
1.54 _exec_pager = new ExternalPager(0, 10 * L4_PAGESIZE);
1.55
1.56 @@ -120,19 +97,19 @@
1.57
1.58 /* Start the pager in a separate thread. */
1.59
1.60 - return start_pager();
1.61 + return ResourceServer(_exec_pager).start_thread(pager);
1.62 }
1.63
1.64 /* Configure the environment for the task. */
1.65
1.66 -long ProcessCreating::configure_task()
1.67 +long ProcessCreating::configure_task(l4_cap_idx_t pager)
1.68 {
1.69 long err = _process.configure_task();
1.70
1.71 if (err)
1.72 return err;
1.73
1.74 - return _process.set_parent(_config.server);
1.75 + return _process.set_parent(pager);
1.76 }
1.77
1.78 /* Create an unbound IPC gate for the region mapper and allocate it in the
1.79 @@ -171,7 +148,7 @@
1.80 and of the associated capabilities, configure the region mapper thread,
1.81 populate its stack, and start the thread. */
1.82
1.83 -long ProcessCreating::start_region_mapper()
1.84 +long ProcessCreating::start_region_mapper(l4_cap_idx_t pager)
1.85 {
1.86 /* Define regions employing dataspaces to provide program segments. */
1.87
1.88 @@ -230,7 +207,7 @@
1.89 /* Configure the environment for the thread, specifying the pager (and
1.90 exception handler plus region mapper). */
1.91
1.92 - long err = _process.configure_thread(_config.server);
1.93 + long err = _process.configure_thread(pager);
1.94
1.95 if (err)
1.96 return err;
1.97 @@ -296,11 +273,11 @@
1.98 if (err)
1.99 return err;
1.100
1.101 - err = init_external_pager();
1.102 + err = init_external_pager(process);
1.103 if (err)
1.104 return err;
1.105
1.106 - err = configure_task();
1.107 + err = configure_task(*process);
1.108 if (err)
1.109 return err;
1.110
1.111 @@ -308,7 +285,7 @@
1.112 if (err)
1.113 return err;
1.114
1.115 - err = start_region_mapper();
1.116 + err = start_region_mapper(*process);
1.117 if (err)
1.118 return err;
1.119
1.120 @@ -316,8 +293,6 @@
1.121 if (err)
1.122 return err;
1.123
1.124 - *process = _config.server;
1.125 -
1.126 /* Discard instances created to initialise the process.
1.127 NOTE: The region mapper payload could be retained instead of being
1.128 reconstructed each time. */