From 83b6103986c65ad580b4b7f038660bfa01f1d087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 21 Feb 2021 19:55:30 +0100 Subject: push child to parents list of children --- src/threads/thread.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/threads/thread.h') diff --git a/src/threads/thread.h b/src/threads/thread.h index e3c426d..b822b64 100644 --- a/src/threads/thread.h +++ b/src/threads/thread.h @@ -4,6 +4,7 @@ #include #include #include +#include "threads/synch.h" #define MAX_FDS 128 /* Max number of file descriptors per thread */ @@ -21,6 +22,24 @@ enum thread_status typedef int tid_t; #define TID_ERROR ((tid_t) -1) /* Error value for tid_t. */ +/* The relationship between a parent and child process. + It is setup by the child in + The child reports its exit status by setting exit_status + and upping exit_sema. + The parent places the parent_child element in its list of children. +*/ +struct parent_child + { + struct list_elem elem; // owned by the parent + + struct semaphore exit_sema; + + struct lock l; + int exit_status; + int alive_count; + + }; + /* Thread priorities. */ #define PRI_MIN 0 /* Lowest priority. */ #define PRI_DEFAULT 31 /* Default priority. */ @@ -98,7 +117,10 @@ struct thread #ifdef USERPROG /* Owned by userprog/process.c. */ uint32_t *pagedir; /* Page directory. */ - struct file **fds; /* Pointer to array of file descriptors. */ + struct file **fds; /* Pointer to array of file descriptors. */ + + struct parent_child parent; // one parent + struct list children; // multiple children #endif /* Owned by thread.c. */ -- cgit v1.2.1