Add child and own process result information to struct thread
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <debug.h>
|
||||
#include <list.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "threads/synch.h"
|
||||
#include "threads/fixed-point.h"
|
||||
|
||||
/* States in a thread's life cycle. */
|
||||
@@ -29,6 +31,19 @@ typedef int tid_t;
|
||||
#define NICE_DEFAULT 0 /* Default niceness. */
|
||||
#define NICE_MAX 20 /* Highest niceness. */
|
||||
|
||||
/* A process result, synchronised between parent and child. */
|
||||
struct process_result
|
||||
{
|
||||
tid_t tid; /* The tid of the child process. */
|
||||
int exit_status; /* The exit status of the child process. Initially set to
|
||||
-1, then to 0 when parent dies, or to exit_status when
|
||||
child dies (whichever happens first). */
|
||||
struct lock lock; /* Lock to synchronise access to the exit_status. */
|
||||
struct semaphore sema; /* Semaphore to signal the parent that the exit_status
|
||||
has been set. */
|
||||
struct list_elem elem; /* List element for the parent's children list. */
|
||||
};
|
||||
|
||||
/* A kernel thread or user process.
|
||||
|
||||
Each thread structure is stored in its own 4 kB page. The
|
||||
@@ -108,6 +123,11 @@ struct thread
|
||||
int nice; /* Nice value for this thread */
|
||||
fp32_t recent_cpu; /* Amount of time this process received */
|
||||
|
||||
/* Process wait properties. */
|
||||
struct process_result *result; /* Result of the process. */
|
||||
struct list child_results; /* List of children's of this thread
|
||||
process results. */
|
||||
|
||||
/* Shared between thread.c and synch.c. */
|
||||
struct list_elem elem; /* List element. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user