PKUOS - Pintos
Pintos source browser for PKU Operating System course
timer.h
Go to the documentation of this file.
1#ifndef DEVICES_TIMER_H
2#define DEVICES_TIMER_H
3
4#include <round.h>
5#include <stdint.h>
6
7/** Number of timer interrupts per second. */
8#define TIMER_FREQ 100
9
10void timer_init (void);
11void timer_calibrate (void);
12
13int64_t timer_ticks (void);
15
16/** Sleep and yield the CPU to other threads. */
18void timer_msleep (int64_t milliseconds);
19void timer_usleep (int64_t microseconds);
20void timer_nsleep (int64_t nanoseconds);
21
22/** Busy waits. */
23void timer_mdelay (int64_t milliseconds);
24void timer_udelay (int64_t microseconds);
25void timer_ndelay (int64_t nanoseconds);
26
27void timer_print_stats (void);
28
29#endif /**< devices/timer.h */
signed long long int int64_t
Definition: stdint.h:16
static int64_t ticks
See [8254] for hardware details of the 8254 timer chip.
Definition: timer.c:21
void timer_udelay(int64_t microseconds)
Sleeps for approximately US microseconds.
Definition: timer.c:144
int64_t timer_elapsed(int64_t)
Returns the number of timer ticks elapsed since THEN, which should be a value once returned by timer_...
Definition: timer.c:82
int64_t timer_ticks(void)
Returns the number of timer ticks since the OS booted.
Definition: timer.c:71
void timer_ndelay(int64_t nanoseconds)
Sleeps execution for approximately NS nanoseconds.
Definition: timer.c:157
void timer_print_stats(void)
devices/timer.h
Definition: timer.c:164
void timer_mdelay(int64_t milliseconds)
Busy waits.
Definition: timer.c:131
void timer_init(void)
Sets up the timer to interrupt TIMER_FREQ times per second, and registers the corresponding interrupt...
Definition: timer.c:36
void timer_calibrate(void)
Calibrates loops_per_tick, used to implement brief delays.
Definition: timer.c:44
void timer_msleep(int64_t milliseconds)
Sleeps for approximately MS milliseconds.
Definition: timer.c:102
void timer_sleep(int64_t ticks)
Sleep and yield the CPU to other threads.
Definition: timer.c:90
void timer_usleep(int64_t microseconds)
Sleeps for approximately US microseconds.
Definition: timer.c:110
void timer_nsleep(int64_t nanoseconds)
Sleeps for approximately NS nanoseconds.
Definition: timer.c:118