diff --git a/src/threads/thread.c b/src/threads/thread.c index 30ca2bd..aeec601 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -4,6 +4,7 @@ #include #include #include +#include "threads/fixed-point.h" #include "threads/flags.h" #include "threads/interrupt.h" #include "threads/intr-stubs.h" @@ -375,8 +376,7 @@ thread_set_nice (int nice UNUSED) int thread_get_nice (void) { - /* Not yet implemented. */ - return 0; + return thread_current ()->nice; } /* Returns 100 times the system load average. */ @@ -391,8 +391,7 @@ thread_get_load_avg (void) int thread_get_recent_cpu (void) { - /* Not yet implemented. */ - return 0; + return fp_round (fp_mul_int (thread_current ()->recent_cpu, 100)); } /* Idle thread. Executes when no other thread is ready to run. diff --git a/src/threads/thread.h b/src/threads/thread.h index 3019926..f85b814 100644 --- a/src/threads/thread.h +++ b/src/threads/thread.h @@ -4,6 +4,7 @@ #include #include #include +#include "threads/fixed-point.h" /* States in a thread's life cycle. */ enum thread_status @@ -95,7 +96,7 @@ struct thread /* MLFQS items */ int nice; /* Nice value for this thread */ - int32_t recent_cpu; /* Amount of time this process received */ + fp32_t recent_cpu; /* Amount of time this process received */ #ifdef USERPROG /* Owned by userprog/process.c. */