KM3NeT CLB
2.0
KM3NeT CLB v2 Embedded Software
|
Simple task scheduler for tasks. More...
Go to the source code of this file.
Macros | |
#define | TASK_ID_NONE -1 |
#define | E_SCHD_INVTASKID ( E_SCHD + 0x01 ) |
Invalid task ID. | |
#define | E_SCHD_INVTASKID_DESCR "Invalid task ID" |
Typedefs | |
typedef void(* | SchdTaskF )() |
Task function typedef. More... | |
Functions | |
bool | schdRegister (SchdTaskF task, bool priority, int *taskId) |
Register a task with the scheduler. More... | |
void | schdRunPeriodic (int taskId, int interval) |
Schedule a task to run periodically. More... | |
void | schdStop (int taskId) |
Stop a scheduled task. More... | |
void | schdRunDelay (int taskId, int interval) |
Schedule a task to run after a delay. More... | |
void | schdRun (int taskId) |
Run a task 'now'. More... | |
void | schdRunIRQ (int taskId) |
Schedule a task from an IRQ. More... | |
void | schdSetEnable (int taskId, bool enabled) |
Enable of disable a task. More... | |
bool | schdTasksPending () |
Checks if there are any tasks pending. More... | |
bool | schdAddIdleTask (SchdTaskF idleTask) |
Adds an idle task, the task which is executed when there is nothing else to do. More... | |
void | schdRunForever () |
Invoked in the main, starts the scheduler. | |
Simple task scheduler for tasks.
Tasks are functions with no argument and no return value which will be invoked by the scheduler. Its a form of cooperative multitasking, so if a function does not return it will stall the entire system.
At the end the scheduler will be run by calling schdRunForever()
. This is than the main-loop.
More information can be found in the tutorial Adding timed processes to the scheduler.
Definition in file scheduler.h.
typedef void(* SchdTaskF)() |
Task function typedef.
Just a simple function with no arguments and no return value.
Definition at line 47 of file scheduler.h.
bool schdAddIdleTask | ( | SchdTaskF | idleTask | ) |
Adds an idle task, the task which is executed when there is nothing else to do.
Note that idle tasks can not be removed.
idleTask | The idle task. |
true | Idle task configured |
false | Idle task not configured |
Definition at line 135 of file scheduler.c.
bool schdRegister | ( | SchdTaskF | task, |
bool | priority, | ||
int * | taskId | ||
) |
Register a task with the scheduler.
task | The function to invoke (e.g. void myFunc() ) |
priority | Whether or not this is a high-priority function. |
taskId | Will be filled in with the task identifier. |
true | All OK |
false | No can do, check errGet(). Most likely there is no more space left. |
Definition at line 95 of file scheduler.c.
void schdRun | ( | int | taskId | ) |
Run a task 'now'.
Well, not really now, but as soon as possible.
taskId | The task to run |
Definition at line 233 of file scheduler.c.
void schdRunDelay | ( | int | taskId, |
int | interval | ||
) |
Schedule a task to run after a delay.
taskId | The task ID to run. |
interval | The delay in milliseconds. |
Definition at line 201 of file scheduler.c.
void schdRunIRQ | ( | int | taskId | ) |
void schdRunPeriodic | ( | int | taskId, |
int | interval | ||
) |
Schedule a task to run periodically.
taskId | The task ID to run. |
interval | The interval in milliseconds. |
Definition at line 212 of file scheduler.c.
void schdSetEnable | ( | int | taskId, |
bool | enabled | ||
) |
Enable of disable a task.
If a task is disabled, it won't run. Not periodically, not when schdRun is invoked.
taskId | The task to run |
bool | true - Enable the task, false - disable the task. |
Definition at line 248 of file scheduler.c.
void schdStop | ( | int | taskId | ) |
Stop a scheduled task.
taskId | The task ID to run. |
Definition at line 223 of file scheduler.c.
bool schdTasksPending | ( | ) |
Checks if there are any tasks pending.
Could be used if you wish to run for as long as there are no other tasks. Though this is not advised.
true | Tasks are pending |
false | Tasks are not pending |
Definition at line 260 of file scheduler.c.