OS
v1.7.5
Documentation
|
The class to interface the OS. More...
#include <kernel.hpp>
Public Member Functions | |
bool | init (const getTickFcn_t tFcn=nullptr, taskFcn_t callbackIdle=nullptr) noexcept |
Task Scheduler initialization. This core method is required and must be called once in the application main thread before any task is being added to the OS. | |
bool | add (task &Task, taskFcn_t callback, const priority_t p, const duration_t t, const iteration_t n, const taskState s=taskState::ENABLED_STATE, void *arg=nullptr) noexcept |
Add a task to the scheduling scheme. The task is scheduled to run every t time units, n times and executing callback method on every pass. | |
bool | add (task &Task, taskFcn_t callback, const priority_t p, void *arg=nullptr) noexcept |
Add a task to the scheduling scheme. This API creates a task with a taskState::DISABLED_STATE state by default, so this task will be executed only, when asynchronous events occurs. However, this behavior can be changed in execution time using task::setTime() or task::setIterations(). | |
bool | add (task &Task, stateMachine &m, const priority_t p, const duration_t t, const taskState s=taskState::ENABLED_STATE, void *arg=nullptr) noexcept |
Add a task to the scheduling scheme running a dedicated state-machine. The task is scheduled to run every t time units in task::PERIODIC mode. The event info will be available as a generic pointer inside the sm::handler_t::Data field. | |
bool | add (task &Task, commandLineInterface &cli, const priority_t p, void *arg=nullptr) noexcept |
Add a task to the scheduling scheme running an AT Command Line Interface. Task will be scheduled as event-triggered task. The parser address will be stored in the event_t::TaskData storage-Pointer. | |
bool | setIdleTask (taskFcn_t callback) noexcept |
Set/Change the callback for the Idle-task. | |
bool | setNameIdleTask (const char *tName) noexcept |
Set the name for the idle task. | |
bool | schedulerRelease (void) noexcept |
Disables the kernel scheduling. The main thread will continue after the core::run() call. | |
bool | setSchedulerReleaseCallback (taskFcn_t callback) noexcept |
Set/Change the scheduler release callback function. | |
bool | remove (task &Task) noexcept |
Remove the task from the scheduling scheme. | |
bool | run (void) noexcept |
Executes the scheduling scheme. It must be called once after the task pool has been defined. | |
bool | notify (notifyMode mode, task &Task, void *eventData=nullptr) noexcept |
Sends a notification generating an asynchronous event. If mode = notifyMode::SIMPLE, the method marks the task as ready for execution and the scheduler planner will launch the task immediately according to the scheduling rules (even if task is disabled) and setting the trigger flag to trigger::byNotificationSimple. If mode = notifyMode::QUEUED, the notification will insert the notification in the FIFO priority queue. The scheduler get this notification as an asynchronous event and the task will be ready for execution according to the queue order (determined by priority), even if task is in a disabled or sleep operational state. When extracted, the scheduler will set trigger flag to trigger::byNotificationQueued. Specific user-data can be passed through, and will be available inside the event_t::EventData field, only in corresponding launch. If the task is in a SLEEP operation state, the scheduler will change the operational state to AWAKEN setting the SHUTDOWN bit. Specific user-data can be passed through, and will be available in the respective callback inside the qOS::event_t::EventData field. | |
bool | notify (notifyMode mode, void *eventData=nullptr) noexcept |
Try to spread a notification among all the tasks in the scheduling scheme. | |
bool | hasPendingNotifications (const task &Task) const noexcept |
Check if the supplied task has pending notifications. | |
bool | eventFlagsModify (task &Task, const taskFlag_t tFlags, const bool action) noexcept |
Modify the EventFlags for the provided task. | |
taskFlag_t | eventFlagsRead (task &Task) const noexcept |
Returns the current value of the task's EventFlags. | |
bool | eventFlagsCheck (task &Task, taskFlag_t flagsToCheck, const bool clearOnExit=true, const bool checkForAll=false) noexcept |
Check for flags set to true inside the task Event-Flags. | |
task * | getTaskByName (const char *name) noexcept |
Tries to find the task that matches the name provided. | |
task * | getTaskByID (size_t id) noexcept |
Tries to find the task that matches the ID provided. | |
bool | yieldToTask (task &Task) noexcept |
Yield the control of the current running task to another task. | |
globalState | getGlobalState (task &Task) const noexcept |
Retrieve the task global-state. | |
bool | add (input::watcher &w) noexcept |
Add an input-watcher so that its function is executed by the kernel. | |
bool | remove (input::watcher &w) noexcept |
Remove an input-watcher so that the kernel stops executing its function. | |
Static Public Member Functions | |
static core & | getInstance (void) noexcept |
Returns a reference to the OS control instance. | |
Static Public Attributes | |
static const priority_t | LOWEST_PRIORITY |
A constant that holds the value of the lowest priority. | |
static const priority_t | MEDIUM_PRIORITY |
A constant that holds the value of the medium priority. | |
static const priority_t | HIGHEST_PRIORITY |
A constant that holds the value of the highest priority. | |
The class to interface the OS.
|
noexcept |
Add an input-watcher so that its function is executed by the kernel.
[in] | w | The input watcher. |
true
if success, otherwise returns false
.
|
noexcept |
Add a task to the scheduling scheme. The task is scheduled to run every t time units, n times and executing callback method on every pass.
[in] | Task | The task node. |
[in] | callback | A pointer to a void callback method with a qOS::event_t parameter as input argument. If user uses the OOP approach for defining a task, you can pass nullptr as argument. |
[in] | p | Task priority Value. [0(min) - Q_PRIORITY_LEVELS(max) ] |
[in] | t | Execution interval (time) given in milliseconds. For immediate execution use t = clock::IMMEDIATE. |
[in] | n | Number of task executions (Integer value). For indefinite execution ( n = task::PERIODIC or task::INDEFINITE ). Tasks do not remember the number of iteration set initially. After the iterations are done, internal iteration counter is 0. To perform another set of iterations, set the number of iterations again. |
[in] | s | Specifies the initial operational state of the task (taskState::ENABLED_STATE, taskState::DISABLED_STATE, taskState::AWAKE_STATE or taskState::AWAKE_STATE(implies taskState::ENABLED_STATE,)). |
[in] | arg | Represents the task arguments. All arguments must be passed by reference and cast to void* . Only one argument is allowed, so, for multiple arguments, create a structure that contains all of the arguments and pass a pointer to that structure. |
true
on success, otherwise returns false
.
|
inlinenoexcept |
Add a task to the scheduling scheme. This API creates a task with a taskState::DISABLED_STATE state by default, so this task will be executed only, when asynchronous events occurs. However, this behavior can be changed in execution time using task::setTime() or task::setIterations().
[in] | Task | The task node. |
[in] | callback | A pointer to a the task callback method with a event_t parameter as input argument. If user uses the OOP approach for defining a task, you can pass nullptr as argument. |
[in] | p | Task priority Value. [0(min) - Q_PRIORITY_LEVELS (max)] |
[in] | arg | Represents the task arguments. All arguments must be passed by reference and cast to void* . |
true
on success, otherwise returns false
.
|
noexcept |
Retrieve the task global-state.
[in] | Task | The task node. |
|
staticnoexcept |
Returns a reference to the OS control instance.
|
noexcept |
Tries to find the task that matches the ID provided.
0
cannot be obtained [in] | id | The value of the task-ID to find. |
nullptr
.
|
noexcept |
Tries to find the task that matches the name provided.
idle
cannot be obtained [in] | name | The string with the name to find. |
nullptr
.
|
noexcept |
Task Scheduler initialization. This core method is required and must be called once in the application main thread before any task is being added to the OS.
[in] | tFcn | The function that provides the tick value. If the user application uses the qOS::clock::sysTick() from the ISR, this parameter can be nullptr . |
[in] | callbackIdle | Callback function to the Idle Task. To disable the Idle-Task activities, ignore this parameter of pass nullptr as argument. |
true
on success. Otherwise return false
.Example : When tick is already provided
Example : When the tick is not provided
|
noexcept |
Remove an input-watcher so that the kernel stops executing its function.
[in] | w | The input-watcher. |
true
if success, otherwise returns false
.
|
noexcept |
Remove the task from the scheduling scheme.
[in] | Task | The task node. |
true
if success, otherwise returns false
.
|
noexcept |
Executes the scheduling scheme. It must be called once after the task pool has been defined.
true
if a release action its performed. In a normal scenario, this function never returns.
|
noexcept |
Disables the kernel scheduling. The main thread will continue after the core::run() call.
|
noexcept |
Set/Change the callback for the Idle-task.
[in] | callback | A pointer to a void callback method with a qOS::event_t parameter as input argument. To disable pass nullptr as argument. |
true
on success. Otherwise return false
.
|
noexcept |
Set the name for the idle task.
[in] | tName | A raw-string with the task name |
true
on success. Otherwise return false
.
|
noexcept |
Set/Change the scheduler release callback function.
[in] | callback | A pointer to a void callback method with a event parameter as input argument. |
true
on success. Otherwise return false
.
|
noexcept |
Yield the control of the current running task to another task.
[in] | Task | The the task to which current control will be yielded. |
true
if success, otherwise returns false
.
|
static |
A constant that holds the value of the highest priority.
|
static |
A constant that holds the value of the lowest priority.
|
static |
A constant that holds the value of the medium priority.