Lazuli
Data Structures | Macros | Typedefs | Functions
task.h File Reference

Base task definition and context description. More...

#include <stdint.h>
#include <Lazuli/common.h>
#include <Lazuli/lazuli.h>
#include <Lazuli/list.h>

Go to the source code of this file.

Data Structures

struct  Task
 Represents a task. More...
 
struct  TaskContextLayout
 Represents the layout of the stack when saving the context of a task. More...
 

Macros

#define NO_MESSAGE   ((lz_task_to_scheduler_message_t)0U)
 No message has to be passed to the scheduler.
 
#define WAIT_ACTIVATION   ((lz_task_to_scheduler_message_t)1U)
 Set the task to wait for its next activation. More...
 
#define WAIT_INTERRUPT   ((lz_task_to_scheduler_message_t)2U)
 Set the task to wait for an interrupt. More...
 
#define TERMINATE_TASK   ((lz_task_to_scheduler_message_t)3U)
 Terminate the task.
 
#define WAIT_MUTEX   ((lz_task_to_scheduler_message_t)4U)
 Wait for a mutex to be unlocked. More...
 
#define WAIT_SOFTWARE_TIMER   ((lz_task_to_scheduler_message_t)5U)
 Set the task to wait for the specified number of time resolution units, using the software timer. More...
 

Typedefs

typedef u_read_write_atomic_t lz_task_to_scheduler_message_t
 Defines the type used to contain a message that a Task can pass to the scheduler after its time slice has expired. More...
 
typedef void(* FuncVoidVoid) (void)
 This type definition is needed to exlude confusion with the 'volatile' type qualifier used in the struct declaration below.
 

Functions

void Task_Abort (void)
 Abort the calling task. More...
 

Detailed Description

Base task definition and context description.

Describes all types and functions related to tasks.

Definition in file task.h.

Macro Definition Documentation

◆ WAIT_ACTIVATION

#define WAIT_ACTIVATION   ((lz_task_to_scheduler_message_t)1U)

Set the task to wait for its next activation.

i.e. It finnished its work without consuming all of its completion time.

Definition at line 46 of file task.h.

◆ WAIT_INTERRUPT

#define WAIT_INTERRUPT   ((lz_task_to_scheduler_message_t)2U)

Set the task to wait for an interrupt.

A parameter representing the interrupt number must accompany this message.

Definition at line 52 of file task.h.

◆ WAIT_MUTEX

#define WAIT_MUTEX   ((lz_task_to_scheduler_message_t)4U)

Wait for a mutex to be unlocked.

A parameter pointing to the mutex must accompany this message.

Definition at line 63 of file task.h.

◆ WAIT_SOFTWARE_TIMER

#define WAIT_SOFTWARE_TIMER   ((lz_task_to_scheduler_message_t)5U)

Set the task to wait for the specified number of time resolution units, using the software timer.

A parameter pointing to the specified number of units must accompany this message.

Definition at line 71 of file task.h.

Typedef Documentation

◆ lz_task_to_scheduler_message_t

Defines the type used to contain a message that a Task can pass to the scheduler after its time slice has expired.

This type is declared read/write atomic because in the definition of struct Task a message can come along with data, pointed by taskToSchedulerMessageParameter. By writing the pointer first, then writing the message code, we can ensure the integrity of the full message (i.e.: message code + data), assuming the execution is "in-order".

Definition at line 35 of file task.h.

Function Documentation

◆ Task_Abort()

void Task_Abort ( void  )

Abort the calling task.

This function can be called when some unrecoverable error occured in the context of a task (e.g. when a mandatory pointer is NULL as a function parameter). This will have the consequence of saving the task context (saving all registers and keeping the call stack) and unscheduling the task.