1.1 --- a/libexec/include/exec/process_creating.h Sat Feb 25 23:39:51 2023 +0100
1.2 +++ b/libexec/include/exec/process_creating.h Sun Feb 26 18:43:52 2023 +0100
1.3 @@ -39,18 +39,20 @@
1.4
1.5 /* External pager configuration. */
1.6
1.7 - ExternalPager _exec_pager;
1.8 + ExternalPager *_exec_pager = NULL;
1.9 ipc_server_config_type _config;
1.10
1.11 + /* Process construction. */
1.12 +
1.13 Process _process;
1.14
1.15 /* Stack and payload descriptions. */
1.16
1.17 ExplicitSegment _rm_stack;
1.18 - Payload *_rm_payload;
1.19 + Payload *_rm_payload = NULL;
1.20
1.21 ExplicitSegment _program_stack;
1.22 - Payload *_program_payload;
1.23 + Payload *_program_payload = NULL;
1.24
1.25 /* IPC gate for communication within the created task, plus allocated
1.26 capability. */
1.27 @@ -82,9 +84,7 @@
1.28 public:
1.29 explicit ProcessCreating(const char *rm_filename);
1.30
1.31 - virtual long start(file_t *file, int argc, const char *argv[]);
1.32 -
1.33 - virtual l4_cap_idx_t get_pager();
1.34 + virtual long start(file_t *file, int argc, const char *argv[], l4_cap_idx_t *process);
1.35 };
1.36
1.37 /* vim: tabstop=2 expandtab shiftwidth=2
2.1 --- a/libexec/lib/src/process_creating.cc Sat Feb 25 23:39:51 2023 +0100
2.2 +++ b/libexec/lib/src/process_creating.cc Sun Feb 26 18:43:52 2023 +0100
2.3 @@ -44,7 +44,6 @@
2.4
2.5 ProcessCreating::ProcessCreating(const char *rm_filename)
2.6 : _rm_filename(rm_filename),
2.7 - _exec_pager(0, 10 * L4_PAGESIZE),
2.8 _rm_stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW),
2.9 _program_stack(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW)
2.10 {
2.11 @@ -60,7 +59,7 @@
2.12 pthread_attr_init(&attr);
2.13 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2.14
2.15 - ipc_server_init_for(&_config, ParentPagerObject, &_exec_pager);
2.16 + ipc_server_init_for(&_config, ParentPagerObject, _exec_pager);
2.17
2.18 long err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &_config);
2.19
2.20 @@ -105,17 +104,19 @@
2.21
2.22 long ProcessCreating::init_external_pager()
2.23 {
2.24 + _exec_pager = new ExternalPager(0, 10 * L4_PAGESIZE);
2.25 +
2.26 /* Initialise pager regions for the region mapper. */
2.27
2.28 for (unsigned int i = 0; i < _rm_payload->segments(); i++)
2.29 {
2.30 if (_rm_payload->segment(i)->loadable())
2.31 - _exec_pager.add(_rm_payload->segment(i)->region());
2.32 + _exec_pager->add(_rm_payload->segment(i)->region());
2.33 }
2.34
2.35 /* Include the region mapper's stack region. */
2.36
2.37 - _exec_pager.add(_rm_stack.region());
2.38 + _exec_pager->add(_rm_stack.region());
2.39
2.40 /* Start the pager in a separate thread. */
2.41
2.42 @@ -280,9 +281,10 @@
2.43 }
2.44
2.45 /* Start a new process for the given payload, providing the indicated program
2.46 - arguments. */
2.47 + arguments, returning a reference to the pager. */
2.48
2.49 -long ProcessCreating::start(file_t *file, int argc, const char *argv[])
2.50 +long ProcessCreating::start(file_t *file, int argc, const char *argv[],
2.51 + l4_cap_idx_t *process)
2.52 {
2.53 long err;
2.54
2.55 @@ -310,14 +312,20 @@
2.56 if (err)
2.57 return err;
2.58
2.59 - return start_program(argc, argv);
2.60 -}
2.61 + err = start_program(argc, argv);
2.62 + if (err)
2.63 + return err;
2.64 +
2.65 + *process = _config.server;
2.66
2.67 -/* Get a reference to the system-level pager for a process. */
2.68 + /* Discard instances created to initialise the process.
2.69 + NOTE: The region mapper payload could be retained instead of being
2.70 + reconstructed each time. */
2.71
2.72 -l4_cap_idx_t ProcessCreating::get_pager()
2.73 -{
2.74 - return _config.server;
2.75 + delete _rm_payload;
2.76 + delete _program_payload;
2.77 +
2.78 + return L4_EOK;
2.79 }
2.80
2.81 /* vim: tabstop=2 expandtab shiftwidth=2
3.1 --- a/libexec/lib/src/process_creator_resource.cc Sat Feb 25 23:39:51 2023 +0100
3.2 +++ b/libexec/lib/src/process_creator_resource.cc Sun Feb 26 18:43:52 2023 +0100
3.3 @@ -65,16 +65,9 @@
3.4
3.5 const char *argv[] = {"<program>"};
3.6
3.7 - long err = _creating.start(program_file, 1, argv);
3.8 -
3.9 - if (err)
3.10 - return err;
3.11 + /* Start the new process, obtaining a reference to it. */
3.12
3.13 - /* Obtain a reference to the pager to interact with the process. */
3.14 -
3.15 - *process = _creating.get_pager();
3.16 -
3.17 - return L4_EOK;
3.18 + return _creating.start(program_file, 1, argv, process);
3.19 }
3.20
3.21 // vim: tabstop=4 expandtab shiftwidth=4