aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include/process.h
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-03-04 11:51:30 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-03-04 11:51:30 +0100
commit503f176e001ddf15e6e32bc912cf10b5764bc23b (patch)
tree2595bc45e582df3ede9241c00656b65866301e38 /src/kernel/include/process.h
parent0934f9943ef7bdec8c2eee3ea31b5e0f1e8a3faf (diff)
downloadkogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.tar.gz
kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.zip
Process exiting & thread termination. IMPORTANT NOTE FOLLOWS.
Threads may now communicate via wait_on(void* ressource) and resume_on (void* ressource). Previous pause() is replaced by wait_on(current_thread) and resume(thread) by resume_on(thread). wait_on(x) may return false, indicating that the reason for returning is NOT that resume_on(x) was called but something else happenned. Typically false indicates that the curent thread is being killed and must terminate its kernel-land processing as soon as possible.
Diffstat (limited to 'src/kernel/include/process.h')
-rw-r--r--src/kernel/include/process.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/kernel/include/process.h b/src/kernel/include/process.h
index 1b4012f..def3397 100644
--- a/src/kernel/include/process.h
+++ b/src/kernel/include/process.h
@@ -56,23 +56,29 @@ typedef struct process {
struct process *parent;
struct process *next_child;
struct process *children;
+
+ mutex_t lock;
} process_t;
typedef void* proc_entry_t;
// ---- Process creation, deletion, waiting, etc.
-// Simple semantics : when a process exits, all its ressources are freed immediately
-// except for the process_t that remains attached to the parent process until it does
-// a wait() and acknowleges the process' ending
-// When a process exits, all the children are orphaned and nobody can wait on them anymore,
-// which is a bad thing : a user process must always wait for all its children !
+// Simple semantics :
+// - When a process exits, all its ressources are freed immediately
+// except for the process_t that remains attached to the parent process until it does
+// a wait() and acknowleges the process' ending
+// - When a process exits, if it has living children then they are terminated too. (a process
+// is seen as a "virtual machine", and spawning sub-process is seen as "sharing some ressources
+// it was allocated to create a new VM", therefore removing the ressource allocated to the
+// parent implies removing the ressource from its children too)
process_t *current_process();
process_t *new_process(process_t *parent);
bool start_process(process_t *p, proc_entry_t entry); // maps a region for user stack
-void process_exit(process_t *p, int status, int exit_code); // exit current process
+void process_exit(process_t *p, int status, int exit_code); // exit specified process (must not be current process)
+void current_process_exit(int status, int exit_code);
bool process_new_thread(process_t *p, proc_entry_t entry, void* sp);
void process_thread_deleted(thread_t *t); // called by threading code when a thread exits