27 for (i = 0; i < 10; i++)
37 for (i = 0; i < 10; i++)
void test_alarm_priority(void)
static struct semaphore wait_sema
static thread_func alarm_priority_thread
Checks that when the alarm clock wakes up threads, the higher-priority threads run first.
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
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,...)
static int64_t start_time
Starts 60 threads that each sleep for 10 seconds, then spin in a tight loop for 60 seconds,...
signed long long int int64_t
void sema_init(struct semaphore *sema, unsigned value)
This file is derived from source code for the Nachos instructional operating system.
void sema_up(struct semaphore *sema)
Up or "V" operation on a semaphore.
void sema_down(struct semaphore *sema)
Down or "P" operation on a semaphore.
bool thread_mlfqs
If false (default), use round-robin scheduler.
const char * thread_name(void)
Returns the name of the running thread.
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_set_priority(int new_priority)
Sets the current thread's priority to NEW_PRIORITY.
#define PRI_DEFAULT
Default priority.
void thread_func(void *aux)
#define PRI_MIN
Thread priorities.
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.