# HG changeset patch # User Paul Boddie # Date 1677433432 -3600 # Node ID 4f4174ed0b1f99a81e6a0367e7426626e2a46431 # Parent d468a4a7fff7abfc87a91448181d9f1cca1b9715 Create a new pager object for each new process. diff -r d468a4a7fff7 -r 4f4174ed0b1f libexec/include/exec/process_creating.h --- a/libexec/include/exec/process_creating.h Sat Feb 25 23:39:51 2023 +0100 +++ b/libexec/include/exec/process_creating.h Sun Feb 26 18:43:52 2023 +0100 @@ -39,18 +39,20 @@ /* External pager configuration. */ - ExternalPager _exec_pager; + ExternalPager *_exec_pager = NULL; ipc_server_config_type _config; + /* Process construction. */ + Process _process; /* Stack and payload descriptions. */ ExplicitSegment _rm_stack; - Payload *_rm_payload; + Payload *_rm_payload = NULL; ExplicitSegment _program_stack; - Payload *_program_payload; + Payload *_program_payload = NULL; /* IPC gate for communication within the created task, plus allocated capability. */ @@ -82,9 +84,7 @@ public: explicit ProcessCreating(const char *rm_filename); - virtual long start(file_t *file, int argc, const char *argv[]); - - virtual l4_cap_idx_t get_pager(); + virtual long start(file_t *file, int argc, const char *argv[], l4_cap_idx_t *process); }; /* vim: tabstop=2 expandtab shiftwidth=2 diff -r d468a4a7fff7 -r 4f4174ed0b1f libexec/lib/src/process_creating.cc --- a/libexec/lib/src/process_creating.cc Sat Feb 25 23:39:51 2023 +0100 +++ b/libexec/lib/src/process_creating.cc Sun Feb 26 18:43:52 2023 +0100 @@ -44,7 +44,6 @@ ProcessCreating::ProcessCreating(const char *rm_filename) : _rm_filename(rm_filename), - _exec_pager(0, 10 * L4_PAGESIZE), _rm_stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW), _program_stack(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW) { @@ -60,7 +59,7 @@ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - ipc_server_init_for(&_config, ParentPagerObject, &_exec_pager); + ipc_server_init_for(&_config, ParentPagerObject, _exec_pager); long err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &_config); @@ -105,17 +104,19 @@ long ProcessCreating::init_external_pager() { + _exec_pager = new ExternalPager(0, 10 * L4_PAGESIZE); + /* Initialise pager regions for the region mapper. */ for (unsigned int i = 0; i < _rm_payload->segments(); i++) { if (_rm_payload->segment(i)->loadable()) - _exec_pager.add(_rm_payload->segment(i)->region()); + _exec_pager->add(_rm_payload->segment(i)->region()); } /* Include the region mapper's stack region. */ - _exec_pager.add(_rm_stack.region()); + _exec_pager->add(_rm_stack.region()); /* Start the pager in a separate thread. */ @@ -280,9 +281,10 @@ } /* Start a new process for the given payload, providing the indicated program - arguments. */ + arguments, returning a reference to the pager. */ -long ProcessCreating::start(file_t *file, int argc, const char *argv[]) +long ProcessCreating::start(file_t *file, int argc, const char *argv[], + l4_cap_idx_t *process) { long err; @@ -310,14 +312,20 @@ if (err) return err; - return start_program(argc, argv); -} + err = start_program(argc, argv); + if (err) + return err; + + *process = _config.server; -/* Get a reference to the system-level pager for a process. */ + /* Discard instances created to initialise the process. + NOTE: The region mapper payload could be retained instead of being + reconstructed each time. */ -l4_cap_idx_t ProcessCreating::get_pager() -{ - return _config.server; + delete _rm_payload; + delete _program_payload; + + return L4_EOK; } /* vim: tabstop=2 expandtab shiftwidth=2 diff -r d468a4a7fff7 -r 4f4174ed0b1f libexec/lib/src/process_creator_resource.cc --- a/libexec/lib/src/process_creator_resource.cc Sat Feb 25 23:39:51 2023 +0100 +++ b/libexec/lib/src/process_creator_resource.cc Sun Feb 26 18:43:52 2023 +0100 @@ -65,16 +65,9 @@ const char *argv[] = {""}; - long err = _creating.start(program_file, 1, argv); - - if (err) - return err; + /* Start the new process, obtaining a reference to it. */ - /* Obtain a reference to the pager to interact with the process. */ - - *process = _creating.get_pager(); - - return L4_EOK; + return _creating.start(program_file, 1, argv, process); } // vim: tabstop=4 expandtab shiftwidth=4