13static void test_sleep (
int thread_cnt, 
int iterations);
 
   42  msg (
"Creating %d threads to sleep %d times each.", thread_cnt, 
iterations);
 
   43  msg (
"Each thread sleeps 10 ticks each time.");
 
   44  msg (
"Within an iteration, all threads should wake up on the same tick.");
 
   49    PANIC (
"couldn't allocate memory for test");
 
   54  test.output_pos = output;
 
   58  for (i = 0; i < thread_cnt; i++)
 
   69  msg (
"iteration 0, thread 0: woke up after %d ticks", output[0]);
 
   70  for (i = 1; i < 
test.output_pos - output; i++) 
 
   71    msg (
"iteration %d, thread %d: woke up %d ticks later",
 
   72         i / thread_cnt, i % thread_cnt, output[i] - output[i - 1]);
 
   87  for (i = 1; i <= 
test->iterations; i++) 
 
static void test_sleep(int thread_cnt, int iterations)
Creates N threads, each of which sleeps a different, fixed duration, M times.
 
void test_alarm_simultaneous(void)
 
static void sleeper(void *)
Sleeper thread.
 
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
 
#define PANIC(...)
Halts the OS, printing the source file name, line number, and function name, plus a user-specific mes...
 
int snprintf(char *buffer, size_t buf_size, const char *format,...)
Like printf(), except that output is stored into BUFFER, which must have space for BUF_SIZE character...
 
void msg(const char *format,...)
 
void * malloc(size_t size)
Obtains and returns a new block of at least SIZE bytes.
 
void free(void *p)
Frees block P, which must have been previously allocated with malloc(), calloc(), or realloc().
 
signed long long int int64_t
 
Information about the test.
 
int * output_pos
Current position in output buffer.
 
int iterations
Number of iterations per thread.
 
int64_t start
Current time at start of test.
 
bool thread_mlfqs
If false (default), use round-robin scheduler.
 
tid_t thread_create(const char *name, int priority, thread_func *function, void *aux)
Creates a new kernel thread named NAME with the given initial PRIORITY, which executes FUNCTION passi...
 
void thread_yield(void)
Yields the CPU.
 
#define PRI_DEFAULT
Default priority.
 
int64_t timer_ticks(void)
Returns the number of timer ticks since the OS booted.
 
void timer_sleep(int64_t ticks)
Sleeps for approximately TICKS timer ticks.