PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
Go to the source code of this file.
Macros | |
#define | TIMER_FREQ 100 |
Number of timer interrupts per second. More... | |
Functions | |
void | timer_init (void) |
Sets up the timer to interrupt TIMER_FREQ times per second, and registers the corresponding interrupt. More... | |
void | timer_calibrate (void) |
Calibrates loops_per_tick, used to implement brief delays. More... | |
int64_t | timer_ticks (void) |
Returns the number of timer ticks since the OS booted. More... | |
int64_t | timer_elapsed (int64_t) |
Returns the number of timer ticks elapsed since THEN, which should be a value once returned by timer_ticks(). More... | |
void | timer_sleep (int64_t ticks) |
Sleep and yield the CPU to other threads. More... | |
void | timer_msleep (int64_t milliseconds) |
Sleeps for approximately MS milliseconds. More... | |
void | timer_usleep (int64_t microseconds) |
Sleeps for approximately US microseconds. More... | |
void | timer_nsleep (int64_t nanoseconds) |
Sleeps for approximately NS nanoseconds. More... | |
void | timer_mdelay (int64_t milliseconds) |
Busy waits. More... | |
void | timer_udelay (int64_t microseconds) |
Sleeps for approximately US microseconds. More... | |
void | timer_ndelay (int64_t nanoseconds) |
Sleeps execution for approximately NS nanoseconds. More... | |
void | timer_print_stats (void) |
devices/timer.h More... | |
void timer_calibrate | ( | void | ) |
Calibrates loops_per_tick, used to implement brief delays.
Definition at line 44 of file timer.c.
References ASSERT, intr_get_level(), INTR_ON, loops_per_tick, printf(), PRIu64, TIMER_FREQ, and too_many_loops().
Referenced by pintos_init().
Returns the number of timer ticks elapsed since THEN, which should be a value once returned by timer_ticks().
Definition at line 82 of file timer.c.
References timer_ticks().
Referenced by alarm_priority_thread(), block_thread(), load_thread(), test_mlfqs_fair(), and timer_sleep().
void timer_init | ( | void | ) |
Sets up the timer to interrupt TIMER_FREQ times per second, and registers the corresponding interrupt.
Definition at line 36 of file timer.c.
References intr_register_ext(), pit_configure_channel(), TIMER_FREQ, and timer_interrupt.
Referenced by pintos_init().
void timer_mdelay | ( | int64_t | ms | ) |
Busy waits.
Busy waits.
Interrupts need not be turned on.
Busy waiting wastes CPU cycles, and busy waiting with interrupts off for the interval between timer ticks or longer will cause timer ticks to be lost. Thus, use timer_msleep() instead if interrupts are enabled.
Definition at line 131 of file timer.c.
References real_time_delay().
void timer_msleep | ( | int64_t | ms | ) |
Sleeps for approximately MS milliseconds.
Interrupts must be turned on.
Definition at line 102 of file timer.c.
References real_time_sleep().
Referenced by reset_channel(), speaker_beep(), and wait_while_busy().
void timer_ndelay | ( | int64_t | ns | ) |
Sleeps execution for approximately NS nanoseconds.
Interrupts need not be turned on.
Busy waiting wastes CPU cycles, and busy waiting with interrupts off for the interval between timer ticks or longer will cause timer ticks to be lost. Thus, use timer_nsleep() instead if interrupts are enabled.
Definition at line 157 of file timer.c.
References real_time_delay().
void timer_nsleep | ( | int64_t | ns | ) |
Sleeps for approximately NS nanoseconds.
Interrupts must be turned on.
Definition at line 118 of file timer.c.
References real_time_sleep().
Referenced by select_device().
void timer_print_stats | ( | void | ) |
Definition at line 164 of file timer.c.
References PRId64, printf(), and timer_ticks().
Referenced by print_stats().
void timer_sleep | ( | int64_t | ticks | ) |
Sleep and yield the CPU to other threads.
Sleep and yield the CPU to other threads.
Interrupts must be turned on.
Definition at line 90 of file timer.c.
References ASSERT, intr_get_level(), INTR_ON, start, thread_yield(), ticks, timer_elapsed(), and timer_ticks().
Referenced by alarm_priority_thread(), load_thread(), real_time_sleep(), sleeper(), test_mlfqs_fair(), and test_sleep().
int64_t timer_ticks | ( | void | ) |
Returns the number of timer ticks since the OS booted.
Definition at line 71 of file timer.c.
References intr_disable(), intr_set_level(), and ticks.
Referenced by alarm_priority_thread(), block_thread(), load_thread(), sleeper(), test_mlfqs_fair(), test_sleep(), timer_elapsed(), timer_print_stats(), and timer_sleep().
void timer_udelay | ( | int64_t | us | ) |
Sleeps for approximately US microseconds.
Interrupts need not be turned on.
Busy waiting wastes CPU cycles, and busy waiting with interrupts off for the interval between timer ticks or longer will cause timer ticks to be lost. Thus, use timer_usleep() instead if interrupts are enabled.
Definition at line 144 of file timer.c.
References real_time_delay().
Referenced by shutdown_reboot().
void timer_usleep | ( | int64_t | us | ) |
Sleeps for approximately US microseconds.
Interrupts must be turned on.
Definition at line 110 of file timer.c.
References real_time_sleep().
Referenced by reset_channel(), and wait_until_idle().