Data Structures | |
struct | TimerEntry_t |
Description of one sleep request. More... | |
Macros | |
#define | IS_PERIODIC(interval) (((interval) >> 31) == 1) |
Determine if interval in sleep entry is periodic or not. | |
#define | GET_SLEEPTIME(interval) ((interval) & (~(1 << 31))) |
Get how long the sleep should take. | |
Functions | |
int | os_usleep (unsigned microseconds) |
Kernel implementation of usleep() syscall. | |
int | os_setitimer (unsigned microseconds) |
Kernel implementation of setitimer() syscall. | |
void | os_timer_init () |
This routine initializes kernel scheduling subsystem. | |
bool | os_schedule_timer (unsigned *delay) |
Provide information on next scheduled event. | |
void | os_run_timer (uint32_t microtime) |
Fire scheduled event. | |
static int | do_set_timed_event (unsigned slot, unsigned interval, bool _periodic) |
Perform heavy lifting of setting timers This routine will store timed event into list of timed events. | |
static int | set_timed_event (unsigned microseconds, bool periodic) |
Find a slot for timed event and store it. | |
static int | cancel_timed_event (Thread_t owner, bool periodic) |
Cancels existing timed event. | |
static void | delay_us (uint32_t period_us) |
Perform short busy wait. | |
static uint32_t | get_sleep_time (uint32_t sleep_from, uint32_t microtime) |
Helper function to calculate time considering type wraparound. | |
Variables | |
struct TimerEntry_t | sleepers [SLEEPERS_MAX] |
List of all delays requested from kernel. | |
#define GET_SLEEPTIME | ( | interval | ) | ((interval) & (~(1 << 31))) |
Get how long the sleep should take.
Will clean the periodicity flag from interval.
#define IS_PERIODIC | ( | interval | ) | (((interval) >> 31) == 1) |
Determine if interval in sleep entry is periodic or not.
|
static |
Cancels existing timed event.
This function is only accessible for periodic timers externally. It allows cancelling of interval timers set previously.
owner | thread which shall own the interval timer |
periodic | true if periodic timer of given thread should be cancelled |
|
static |
Perform short busy wait.
This will perform busywait in the context of current thread. Useful to do short waits for I/O.
period_us | how long the wait should take |
|
static |
Perform heavy lifting of setting timers This routine will store timed event into list of timed events.
If event is not periodic, it will also stop thread (os_usleep semantics).
slot | number of slot in sleepers list |
interval | amount of us for which thread should sleep |
_periodic | true if timer should be periodic, false otherwise |
|
static |
Helper function to calculate time considering type wraparound.
This function will calculate the final time considering timer wraparound.
sleep_from | time at which the sleep starts (microseconds) |
microtime | duration of sleep (microseconds) |
void os_run_timer | ( | uint32_t | microtime | ) |
Fire scheduled event.
Will find and run scheduled event.
microtime | current processor time in microseconds |
bool os_schedule_timer | ( | unsigned * | delay | ) |
Provide information on next scheduled event.
This function informs caller about delay until next scheduled event. Next scheduled event may be either wake-up of sleeped thread, or interval timer.
[out] | delay | address of buffer, where delay to next scheduled event will be written |
int os_setitimer | ( | unsigned | microseconds | ) |
Kernel implementation of setitimer() syscall.
See setitimer for details on arguments.
void os_timer_init | ( | ) |
This routine initializes kernel scheduling subsystem.
It is necessary to call this routine before first call to either timer syscalls, or os_run_timer otherwise things will go wrong.
int os_usleep | ( | unsigned | microseconds | ) |
|
static |
Find a slot for timed event and store it.
This is actual execution core for both os_usleep and os_setitimer functions. It will find free slot or slot already occupied by calling thread and will set / update timeout values.
microseconds | time for which thread should sleep / wait for event |
periodic | true if this event is periodic |
struct TimerEntry_t sleepers[SLEEPERS_MAX] |
List of all delays requested from kernel.
This structure contains all scheduled sleeps requested by all threads. Every thread can technically request one periodic timer and one one-shot delay.