113 int last_elapsed = 0;
119 msg (
"Sleeping 10 seconds to allow recent_cpu to decay, please wait...");
130 if (elapsed % (
TIMER_FREQ * 2) == 0 && elapsed > last_elapsed)
135 msg (
"After %d seconds, recent_cpu is %d.%02d, load_avg is %d.%02d.",
137 recent_cpu / 100, recent_cpu % 100,
138 load_avg / 100, load_avg % 100);
139 if (elapsed_seconds >= 180)
142 last_elapsed = elapsed;
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
void msg(const char *format,...)
static int64_t start_time
Starts 60 threads that each sleep for 10 seconds, then spin in a tight loop for 60 seconds,...
void test_mlfqs_recent_1(void)
Checks that recent_cpu is calculated properly for the case of a single ready process.
#define DIV_ROUND_UP(X, STEP)
Yields X divided by STEP, rounded up.
signed long long int int64_t
bool thread_mlfqs
If false (default), use round-robin scheduler.
int thread_get_recent_cpu(void)
Returns 100 times the current thread's recent_cpu value.
int thread_get_load_avg(void)
Returns 100 times the system load average.
int64_t timer_ticks(void)
Returns the number of timer ticks since the OS booted.
int64_t timer_elapsed(int64_t then)
Returns the number of timer ticks elapsed since THEN, which should be a value once returned by timer_...
void timer_sleep(int64_t ticks)
Sleeps for approximately TICKS timer ticks.
#define TIMER_FREQ
Number of timer interrupts per second.