|
PebbleOS
|
Low priority background task (KernelBG) running deferred work. More...
Typedefs | |
| typedef void(* | SystemTaskEventCallback) (void *data) |
| System task callback. | |
Functions | |
| void | system_task_init (void) |
| Create the KernelBG task. | |
| void | system_task_timer_init (void) |
| Set up the timers used by the system task, once timers are available. | |
| void | system_task_watchdog_feed (void) |
| Feed the KernelBG watchdog. | |
| bool | system_task_add_callback_from_isr (SystemTaskEventCallback cb, void *data) |
| Queue a callback from an ISR. | |
| bool | system_task_add_callback_droppable (SystemTaskEventCallback cb, void *data) |
| Queue a callback without waiting, dropping it if the queue is full. | |
| bool | system_task_add_callback_from_isr_droppable (SystemTaskEventCallback cb, void *data) |
| ISR flavour of system_task_add_callback_droppable(). | |
| bool | system_task_add_callback_from_isr_droppable_raised (SystemTaskEventCallback cb, void *data) |
| Queue a droppable callback that raises KernelBG priority until it has run. | |
| bool | system_task_add_callback (SystemTaskEventCallback cb, void *data) |
| Queue a callback from task context. | |
| void | system_task_block_callbacks (bool block) |
| Block or unblock new callbacks. | |
| uint32_t | system_task_get_available_space (void) |
| Get the free space of the queue used by the calling task. | |
| void * | system_task_get_current_callback (void) |
| Get the callback being run, for debugging. | |
| void | system_task_enable_raised_priority (bool is_raised) |
| Acquire or release a reference raising KernelBG priority. | |
| bool | system_task_is_ready_to_run (void) |
| Check whether KernelBG is ready to run. | |
Low priority background task (KernelBG) running deferred work.
ISRs and higher priority tasks marshal units of work onto KernelBG by queueing callbacks, which run one at a time in FIFO order. Callbacks are covered by a task watchdog; long ones must call system_task_watchdog_feed() regularly. When KernelBG starves, the app task is briefly throttled.
The enqueue variants differ in what happens when the queue is full:
_droppable variants do not wait and return false.| typedef void(* SystemTaskEventCallback) (void *data) |
System task callback.
| data | Context given when queueing the callback. |
| bool system_task_add_callback | ( | SystemTaskEventCallback | cb, |
| void * | data | ||
| ) |
Queue a callback from task context.
From the app task, waits for space as long as needed. From other tasks, waits up to 3 seconds, then resets the system.
| cb | Callback to run on KernelBG. |
| data | Context passed to cb. |
| bool system_task_add_callback_droppable | ( | SystemTaskEventCallback | cb, |
| void * | data | ||
| ) |
Queue a callback without waiting, dropping it if the queue is full.
Callable from task or ISR context, including with interrupts locked. Never resets on failure. Only use it when losing the callback is tolerable or the caller can retry later.
| cb | Callback to run on KernelBG. |
| data | Context passed to cb. |
| bool system_task_add_callback_from_isr | ( | SystemTaskEventCallback | cb, |
| void * | data | ||
| ) |
Queue a callback from an ISR.
Does not wait. A full queue resets the system.
| cb | Callback to run on KernelBG. |
| data | Context passed to cb. |
| bool system_task_add_callback_from_isr_droppable | ( | SystemTaskEventCallback | cb, |
| void * | data | ||
| ) |
ISR flavour of system_task_add_callback_droppable().
| cb | Callback to run on KernelBG. |
| data | Context passed to cb. |
| bool system_task_add_callback_from_isr_droppable_raised | ( | SystemTaskEventCallback | cb, |
| void * | data | ||
| ) |
Queue a droppable callback that raises KernelBG priority until it has run.
The priority is raised while the callback is pending or running, and released after it returns. Nothing is retained if the callback is dropped.
| cb | Callback to run on KernelBG. |
| data | Context passed to cb. |
| void system_task_block_callbacks | ( | bool | block | ) |
Block or unblock new callbacks.
| block | True to reject new callbacks, false to accept them. |
| void system_task_enable_raised_priority | ( | bool | is_raised | ) |
Acquire or release a reference raising KernelBG priority.
While at least one reference is held, KernelBG runs at the priority of KernelMain.
| is_raised | True to acquire a reference, false to release one. Calls must be balanced. |
| uint32_t system_task_get_available_space | ( | void | ) |
Get the free space of the queue used by the calling task.
| void * system_task_get_current_callback | ( | void | ) |
Get the callback being run, for debugging.
| void system_task_init | ( | void | ) |
Create the KernelBG task.
| bool system_task_is_ready_to_run | ( | void | ) |
Check whether KernelBG is ready to run.
| void system_task_timer_init | ( | void | ) |
Set up the timers used by the system task, once timers are available.
| void system_task_watchdog_feed | ( | void | ) |
Feed the KernelBG watchdog.
Call it regularly from callbacks that take a while to run.