|
ginnOS
The reference: libc, the libraries and the kernel
|
Go to the source code of this file.
Data Structures | |
| struct | timed_queue |
| a wait queue with a deadline. More... | |
Macros | |
| #define | TIMER_HZ PIT_FREQUENCY_HZ |
| kernel timing: the tick count and wait queues with a deadline. | |
| #define | TIMER_NEVER UINT64_MAX |
| #define | TIMER_POLL_HOOKS 6 |
Typedefs | |
| typedef struct timed_queue | timed_queue_t |
| a wait queue with a deadline. | |
| typedef void(*) | timer_poll_fn(uint64_t now) |
| a function the timer interrupt calls on every tick (now: the tick count). | |
Functions | |
| void | timed_queue_init (timed_queue_t *queue) |
| set up a queue and add it to the ones timer_tick checks. | |
| void | timed_queue_block (timed_queue_t *queue, uint64_t deadline) |
| sleep on a queue until it is woken or the deadline tick has come. | |
| void | timed_queue_block_interruptible (timed_queue_t *queue, uint64_t deadline) |
| like timed_queue_block, but a signal for the process also wakes it. | |
| void | timed_queue_block_locked (timed_queue_t *queue, uint64_t deadline, spinlock_t *lock) |
| sleep on a queue until it is woken or the deadline tick has come, with a spinlock released while asleep and held again on return. | |
| void | timed_queue_block_locked_interruptible (timed_queue_t *queue, uint64_t deadline, spinlock_t *lock) |
| like timed_queue_block_locked, but a signal for the process also wakes it. | |
| void | timed_queue_wait_word (timed_queue_t *queue, uint64_t deadline, const volatile uint32_t *word, uint32_t seen) |
| sleep on a queue while a counter has the value the caller saw, until it is woken, the deadline tick comes or a signal arrives. | |
| void | timed_queue_wake_all (timed_queue_t *queue) |
| wake every waiter of a queue (they re-check their condition). | |
| void | timer_tick (uint64_t now) |
| called from the timer interrupt on every tick: wake the queues whose earliest deadline has passed. | |
| void | timer_add_poll_hook (timer_poll_fn fn) |
| call fn on every tick, in the timer interrupt (interrupts off). | |
| uint64_t | timer_now (void) |
| the current tick. | |
| uint64_t | timer_ms_to_ticks (uint32_t ms) |
| the number of ticks that covers at least a time span (rounded up). | |
| #define TIMER_HZ PIT_FREQUENCY_HZ |
kernel timing: the tick count and wait queues with a deadline.
the PIT interrupts TIMER_HZ times a second; each interrupt is one tick. a timed queue is a wait queue that a waiter can also leave when a given tick arrives. the timer interrupt wakes every waiter of a queue when the earliest deadline on it has passed; the waiters then check their own deadline and condition, and sleep again if they still have to wait.
| #define TIMER_NEVER UINT64_MAX |
| #define TIMER_POLL_HOOKS 6 |
| typedef struct timed_queue timed_queue_t |
a wait queue with a deadline.
| typedef void(*) timer_poll_fn(uint64_t now) |
a function the timer interrupt calls on every tick (now: the tick count).
| void timed_queue_init | ( | timed_queue_t * | queue | ) |
set up a queue and add it to the ones timer_tick checks.
call once per queue (queues live as long as the kernel).
| queue | the queue. |
| void timed_queue_block | ( | timed_queue_t * | queue, |
| uint64_t | deadline ) |
sleep on a queue until it is woken or the deadline tick has come.
for a wait on time only: a wake between the caller's check and the sleep is lost. the caller re-checks the deadline after waking.
| queue | the queue. |
| deadline | the tick to wake at, or TIMER_NEVER. |
| void timed_queue_block_interruptible | ( | timed_queue_t * | queue, |
| uint64_t | deadline ) |
like timed_queue_block, but a signal for the process also wakes it.
| void timed_queue_block_locked | ( | timed_queue_t * | queue, |
| uint64_t | deadline, | ||
| spinlock_t * | lock ) |
sleep on a queue until it is woken or the deadline tick has come, with a spinlock released while asleep and held again on return.
the caller tests its condition with the lock held, and the waker takes the lock to change it, so a wake between the test and the sleep is not lost.
| queue | the queue. |
| deadline | the tick to wake at, or TIMER_NEVER. |
| lock | a lock taken with spin_lock_irqsave() by the caller. |
| void timed_queue_block_locked_interruptible | ( | timed_queue_t * | queue, |
| uint64_t | deadline, | ||
| spinlock_t * | lock ) |
like timed_queue_block_locked, but a signal for the process also wakes it.
| void timed_queue_wait_word | ( | timed_queue_t * | queue, |
| uint64_t | deadline, | ||
| const volatile uint32_t * | word, | ||
| uint32_t | seen ) |
sleep on a queue while a counter has the value the caller saw, until it is woken, the deadline tick comes or a signal arrives.
a waker changes the counter, then wakes the queue: a change before the sleep is seen, a later one finds the process asleep. for waits on many things at once (poll), where no one lock guards the condition.
| queue | the queue. |
| deadline | the tick to wake at, or TIMER_NEVER. |
| word | the counter. |
| seen | the value the caller read before it tested its condition. |
| void timed_queue_wake_all | ( | timed_queue_t * | queue | ) |
wake every waiter of a queue (they re-check their condition).
| queue | the queue. |
| void timer_tick | ( | uint64_t | now | ) |
called from the timer interrupt on every tick: wake the queues whose earliest deadline has passed.
| now | the current tick. |
| void timer_add_poll_hook | ( | timer_poll_fn | fn | ) |
call fn on every tick, in the timer interrupt (interrupts off).
for drivers that poll their device, such as the USB keyboard. there is room for TIMER_POLL_HOOKS functions; more are ignored.
| uint64_t timer_now | ( | void | ) |
the current tick.