implement thread_get_nice & thread_get_recent_cpu
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "threads/fixed-point.h"
|
||||||
#include "threads/flags.h"
|
#include "threads/flags.h"
|
||||||
#include "threads/interrupt.h"
|
#include "threads/interrupt.h"
|
||||||
#include "threads/intr-stubs.h"
|
#include "threads/intr-stubs.h"
|
||||||
@@ -399,8 +400,7 @@ thread_get_load_avg (void)
|
|||||||
int
|
int
|
||||||
thread_get_recent_cpu (void)
|
thread_get_recent_cpu (void)
|
||||||
{
|
{
|
||||||
/* Not yet implemented. */
|
return fp_round (fp_mul_int (thread_current ()->recent_cpu, 100));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Idle thread. Executes when no other thread is ready to run.
|
/* Idle thread. Executes when no other thread is ready to run.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <list.h>
|
#include <list.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "threads/fixed-point.h"
|
||||||
|
|
||||||
/* States in a thread's life cycle. */
|
/* States in a thread's life cycle. */
|
||||||
enum thread_status
|
enum thread_status
|
||||||
@@ -95,7 +96,7 @@ struct thread
|
|||||||
|
|
||||||
/* MLFQS items */
|
/* MLFQS items */
|
||||||
int nice; /* Nice value for this thread */
|
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
|
#ifdef USERPROG
|
||||||
/* Owned by userprog/process.c. */
|
/* Owned by userprog/process.c. */
|
||||||
|
|||||||
Reference in New Issue
Block a user