+/* Verifies that a single busy thread raises the load average to
+ 0.5 in 38 to 45 seconds. The expected time is 42 seconds, as
+ you can verify:
+ perl -e '$i++,$a=(59*$a+1)/60while$a<=.5;print "$i\n"'
+
+ Then, verifies that 10 seconds of inactivity drop the load
+ average back below 0.5 again. */
+
#include <stdio.h>
#include "tests/threads/tests.h"
#include "threads/init.h"
int elapsed;
int load_avg;
- ASSERT (enable_mlfqs);
+ ASSERT (thread_mlfqs);
msg ("spinning for up to 45 seconds, please wait...");
load_avg = thread_get_load_avg ();
ASSERT (load_avg >= 0);
elapsed = timer_elapsed (start_time) / TIMER_FREQ;
- if (load_avg > 50)
- break;
- else if (load_avg > 100)
+ if (load_avg > 100)
fail ("load average is %d.%02d "
"but should be between 0 and 1 (after %d seconds)",
load_avg / 100, load_avg % 100, elapsed);
+ else if (load_avg > 50)
+ break;
else if (elapsed > 45)
fail ("load average stayed below 0.5 for more than 45 seconds");
}