# HG changeset patch # User Paul Boddie # Date 1679183359 -3600 # Node ID 86d76cd9a8d37e082a4cb72b59b4511d8f1c28c7 # Parent 6bccfdae3fe57f9f9f7a90385f8aaf0da28c9cd8 Made the process creation activity sequential and introduced a missing reset operation so that more than one process can be successfully created. diff -r 6bccfdae3fe5 -r 86d76cd9a8d3 libexec/include/exec/process.h --- a/libexec/include/exec/process.h Sun Mar 19 00:48:15 2023 +0100 +++ b/libexec/include/exec/process.h Sun Mar 19 00:49:19 2023 +0100 @@ -89,6 +89,8 @@ public: explicit Process(); + void reset(); + l4_cap_idx_t allocate_cap(); long configure_task(l4_cap_idx_t *task, l4_cap_idx_t *mapped_task, diff -r 6bccfdae3fe5 -r 86d76cd9a8d3 libexec/include/exec/process_creating.h --- a/libexec/include/exec/process_creating.h Sun Mar 19 00:48:15 2023 +0100 +++ b/libexec/include/exec/process_creating.h Sun Mar 19 00:49:19 2023 +0100 @@ -21,6 +21,8 @@ #pragma once +#include + #include #include #include @@ -34,6 +36,10 @@ class ProcessCreating { protected: + std::mutex _lock; + + /* Region mapper program filename. */ + const char *_rm_filename; /* External pager configuration. */ diff -r 6bccfdae3fe5 -r 86d76cd9a8d3 libexec/lib/src/process.cc --- a/libexec/lib/src/process.cc Sun Mar 19 00:48:15 2023 +0100 +++ b/libexec/lib/src/process.cc Sun Mar 19 00:49:19 2023 +0100 @@ -54,6 +54,11 @@ Process::Process() { + reset(); +} + +void Process::reset() +{ _thread_number = 0; /* Populate the common initial environment for the threads. */ @@ -89,6 +94,11 @@ long Process::create_task(unsigned int threads) { + /* Reset the process if it has already been used. */ + + if (_thread_number) + reset(); + _task = ipc_cap_alloc(); if (l4_is_invalid_cap(_task)) diff -r 6bccfdae3fe5 -r 86d76cd9a8d3 libexec/lib/src/process_creating.cc --- a/libexec/lib/src/process_creating.cc Sun Mar 19 00:48:15 2023 +0100 +++ b/libexec/lib/src/process_creating.cc Sun Mar 19 00:49:19 2023 +0100 @@ -348,12 +348,14 @@ long ProcessCreating::start(int argc, const char *argv[], l4_cap_idx_t *process) { - file_t *file = client_open(argv[0], O_RDONLY); - long err; + std::lock_guard guard(_lock); /* Open the program file, handling any error conditions. If successfully opened, it will be closed when the process terminates. */ + file_t *file = client_open(argv[0], O_RDONLY); + long err; + if (file == NULL) return -L4_EIO;