|
| task ()=default |
|
virtual | ~task () |
|
priority_t | getPriority (void) const noexcept |
| Retrieve the current task priority.
|
|
bool | setPriority (const priority_t pValue) noexcept |
| Set/Change the task priority value.
|
|
cycles_t | getCycles (void) const noexcept |
| Retrieve the number of task activations.
|
|
taskState | getState (void) const noexcept |
| Retrieve the task operational state.
|
|
bool | setState (const taskState s) noexcept |
| Set the task operational state.
|
|
bool | suspend (void) noexcept |
| Put the task into a disabled state.
|
|
bool | disable (void) noexcept |
| Put the task into a disabled state.
|
|
bool | resume (void) noexcept |
| Put the task into a enabled state.
|
|
bool | enable (void) noexcept |
| Put the task into a enabled state.
|
|
bool | asleep (void) noexcept |
| Put the task into a sleep state. The task can't be triggered by the lower precedence events.
|
|
bool | awake (void) noexcept |
| Put the task into a normal operation state. Here the task will be able to catch any kind of events.
|
|
bool | isEnabled (void) const noexcept |
| Retrieve the enabled/disabled state.
|
|
void | setIterations (const iteration_t iValue) noexcept |
| Set/Change the number of task iterations.
|
|
bool | setTime (const qOS::duration_t tValue) noexcept |
| Set/Change the Task execution interval.
|
|
bool | setCallback (const taskFcn_t tCallback) noexcept |
| Set/Change the task callback function.
|
|
bool | setData (void *arg) noexcept |
| Set the task data.
|
|
bool | setName (const char *tName) noexcept |
| Set the task name.
|
|
const char * | getName (void) const noexcept |
| Retrieves the task name.
|
|
size_t | getID (void) const noexcept |
| Retrieves the Task ID number.
|
|
bool | attachQueue (queue &q, const queueLinkMode mode, const size_t arg=1U) noexcept |
| Attach a queue to the Task.
|
|
void *const & | getBindedObject (void) const noexcept |
| Retrieves a pointer to the object binded to the task, could be either a state-machine or a command-line-interface.
|
|
queue * | getQueue (void) noexcept |
| Retrieves a pointer to the queue attached to the task.
|
|
A task node object.
Like many operating systems, the basic unit of work is the task. Tasks can perform certain functions, which could require periodic or one-time execution, update of specific variables or waiting for specific events. Tasks also could be controlling specific hardware or be triggered by hardware interrupts. In the QuarkTS OS, a task is seen as a node concept that links together:
- Program code performing specific task activities (callback function)
- Execution interval (time)
- Number of execution (iterations)
- Event-based data
The OS uses a Task Control Block(TCB) to represent each task, storing essential information about task management and execution. Part of this information also includes link-pointers that allows it to be part of one of the lists available in the Kernel Control Block (KCB).
Each task performs its activities via a callback function and each of them is responsible for supporting cooperative multitasking by being “good neighbors”, i.e., running their callback methods quickly in a non-blocking way and releasing control back to the scheduler as soon as possible (returning). Every task node, must be defined using the qOS::task class and the callback is defined as a function that returns void and takes a event_t data structure as its only parameter (This input argument can be used later to get event information.
Example :
void UserTask_Callback(
event_t e ) {
}
The task argument with all the regarding information of the task execution.
Definition task.hpp:105
A task node object.
Definition task.hpp:348
OS/Kernel interfaces.
Definition bytebuffer.hpp:7
- Attention
- All tasks in QuarkTS must ensure their completion to return the CPU control back to the scheduler, otherwise, the scheduler will hold the execution-state for that task, preventing the activation of other tasks.
- Note
- Do not access any member of this structure directly.
bool qOS::task::attachQueue |
( |
queue & | q, |
|
|
const queueLinkMode | mode, |
|
|
const size_t | arg = 1U ) |
|
noexcept |
Attach a queue to the Task.
- Parameters
-
[in] | q | The queue object |
[in] | mode | Attach mode. This implies the event that will trigger the task according to one of the following modes: |
queueLinkMode::QUEUE_RECEIVER : The task will be triggered if there are elements in the Queue. Data will be extracted automatically in every trigger and will be available in the event_t::EventData field.
queueLinkMode::QUEUE_FULL : The task will be triggered if the Queue is full. A pointer to the queue will be available in the event_t::EventData field.
queueLinkMode::QUEUE_COUNT : The task will be triggered if the count of elements in the queue reach the specified value. A pointer to the queue will be available in the event_t::EventData field.
queueLinkMode::QUEUE_EMPTY : The task will be triggered if the queue is empty. A pointer to the queue will be available in the event_t::EventData field.
- Parameters
-
[in] | arg | This argument defines if the queue will be attached (1u) or detached (0u) from the task. If the queueLinkMode::QUEUE_COUNT mode is specified, this value will be used to check the element count of the queue. A zero value will act as a detach action. |
- Returns
- Returns
true
on success, otherwise returns false
.
bool qOS::task::setState |
( |
const taskState | s | ) |
|
|
noexcept |
Set the task operational state.
- Parameters
-
[in] | s | Use one of the following values: |
taskState::ENABLED_STATE : Task will be able to catch all the events. ( ENABLE_Bit=1
)
taskState::DISABLED_STATE : Time events will be discarded. The task catch asynchronous events. ( ENABLE_Bit=0
)
taskState::ASLEEP_STATE : Put the task into a sleep operability state. The task can't be triggered by the lower precedence events. ( SHUTDOWN_Bit=0
)
taskState::AWAKE_STATE : Put the task into the previous state before it was put in the sleep state.( SHUTDOWN_Bit=1
)
- Returns
true
on success. Otherwise return false
.