summaryrefslogtreecommitdiffstats
path: root/src/threads/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/threads/thread.h')
-rw-r--r--src/threads/thread.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/threads/thread.h b/src/threads/thread.h
index 0039560..a3bc814 100644
--- a/src/threads/thread.h
+++ b/src/threads/thread.h
@@ -4,6 +4,9 @@
#include <debug.h>
#include <list.h>
#include <stdint.h>
+#include "threads/synch.h"
+
+#define MAX_FDS 128 /* Max number of file descriptors per thread */
/* States in a thread's life cycle. */
enum thread_status
@@ -19,6 +22,23 @@ 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.
+ The child reports its exit status by setting exit_status.
+ The parent places the parent_child element in its list of children.
+*/
+struct parent_child
+ {
+ struct list_elem elem; // owned by the parent
+
+ // exit_status is readable by the parent
+ struct semaphore exit_sema;
+ int exit_status;
+
+ struct lock l;
+ int alive_count;
+ tid_t child_tid;
+ };
+
/* Thread priorities. */
#define PRI_MIN 0 /* Lowest priority. */
#define PRI_DEFAULT 31 /* Default priority. */
@@ -80,6 +100,7 @@ typedef int tid_t;
only because they are mutually exclusive: only a thread in the
ready state is on the run queue, whereas only a thread in the
blocked state is on a semaphore wait list. */
+
struct thread
{
/* Owned by thread.c. */
@@ -95,6 +116,11 @@ struct thread
#ifdef USERPROG
/* Owned by userprog/process.c. */
uint32_t *pagedir; /* Page directory. */
+ struct file **fds; /* Pointer to array of file descriptors. */
+ bool load_success;
+
+ struct parent_child *parent; // one parent
+ struct list children; // multiple children
#endif
/* Owned by thread.c. */