Lazuli
Data Structures | Typedefs | Enumerations | Functions
lazuli.h File Reference

The public API of the Lazuli kernel. More...

#include <stdint.h>
#include <Lazuli/common.h>
#include <Lazuli/config.h>

Go to the source code of this file.

Data Structures

struct  Lz_TaskConfiguration
 Represents the configuration of a task. More...
 

Typedefs

typedef int8_t lz_task_priority_t
 Represents the priority of a task, as a signed integer. More...
 
typedef uint16_t lz_u_resolution_unit_t
 Represents the type used for the system clock resolution unit, as an unsigned integer.
 

Enumerations

enum  Lz_SchedulingPolicy {
  CYCLIC_RT = 0,
  PRIORITY_RT
}
 Defines the possible scheduling policies for a Lazuli user task. More...
 

Functions

bool Lz_RegisterTask (void(*const taskEntryPoint)(void), Lz_TaskConfiguration *taskConfiguration)
 Register a new task. More...
 
void Lz_TaskConfiguration_Init (Lz_TaskConfiguration *const taskConfiguration)
 Initialize an Lz_TaskConfiguration with default values for all parameters. More...
 
void Lz_Run (void)
 Run the scheduler. More...
 
void Lz_Task_WaitInterrupt (uint8_t interruptCode)
 Wait for a specific interrupt to occur. More...
 
char const * Lz_Task_GetName (void)
 Get the name of the calling task. More...
 
void Lz_Task_Terminate (void)
 Terminate the calling task. More...
 
void Lz_Task_WaitActivation (void)
 Set the calling task to wait for its next activation. More...
 
void Lz_WaitTimer (lz_u_resolution_unit_t units)
 Set the calling task to wait for the specified number of time resolution units (time slices), using the software timer. More...
 

Detailed Description

The public API of the Lazuli kernel.

This file describes the public (user) API of the Lazuli kernel. It defines public types and functions that can by used by user main code and tasks.

Definition in file lazuli.h.

Typedef Documentation

◆ lz_task_priority_t

Represents the priority of a task, as a signed integer.

The higher the value, the higher the priority.

Definition at line 30 of file lazuli.h.

Enumeration Type Documentation

◆ Lz_SchedulingPolicy

Defines the possible scheduling policies for a Lazuli user task.

Attention
The constants are defined from the highest priority policy to the lowest. i.e. A lower value means a higher priority.
Enumerator
CYCLIC_RT 

Cyclic real-time scheduling.

PRIORITY_RT 

Priority time sliced real-time scheduling.

Equivalent to POSIX SCHED_RR.

Definition at line 44 of file lazuli.h.

Function Documentation

◆ Lz_RegisterTask()

bool Lz_RegisterTask ( void(*)(void)  taskEntryPoint,
Lz_TaskConfiguration taskConfiguration 
)

Register a new task.

If an error occured during registration of the task false is returned and the task is not included in the set of tasks that will be run.

Parameters
taskEntryPointThe entry point of the task to register. i.e. A pointer to the function representing the task.
taskConfigurationA pointer to an Lz_TaskConfiguration containing the configuration of the task being registered. If NULL is passed, then default values are applied for all parameters.
Returns
  • true if the task has been registered without error.
  • false if an error occured during registration.

Definition at line 758 of file scheduler.c.

◆ Lz_TaskConfiguration_Init()

void Lz_TaskConfiguration_Init ( Lz_TaskConfiguration *const  taskConfiguration)

Initialize an Lz_TaskConfiguration with default values for all parameters.

No function is provided for allocating a new Lz_TaskConfiguration. So it is strongly advised to allocate the Lz_TaskConfiguration parameter on the stack before calling this function.

Parameters
taskConfigurationA pointer to the Lz_TaskConfiguration to initialize.

Definition at line 746 of file scheduler.c.

◆ Lz_Run()

void Lz_Run ( void  )

Run the scheduler.

Start scheduling tasks.

Definition at line 765 of file scheduler.c.

◆ Lz_Task_WaitInterrupt()

void Lz_Task_WaitInterrupt ( uint8_t  interruptCode)

Wait for a specific interrupt to occur.

Puts the calling task to sleep until the specified interrupt occurs.

Parameters
interruptCodeThe code of the interrupt to wait for.
Attention
Only tasks with scheduling policy PRIORITY_RT can wait for interrupts.

Definition at line 793 of file scheduler.c.

◆ Lz_Task_GetName()

char const* Lz_Task_GetName ( void  )

Get the name of the calling task.

Returns
A pointer to a string containing the name of the current running task, or NULL if the task has no name.

Definition at line 779 of file scheduler.c.

◆ Lz_Task_Terminate()

void Lz_Task_Terminate ( void  )

Terminate the calling task.

The context of the task will be saved on its stack.

Calling this function has the same effect than returning from the task's main function.

The terminated task will never be scheduled again.

Definition at line 815 of file scheduler.c.

◆ Lz_Task_WaitActivation()

void Lz_Task_WaitActivation ( void  )

Set the calling task to wait for its next activation.

May be used if the task finnished its work without consuming all of its completion time.

Attention
Only tasks with scheduling policy CYCLIC_RT can wait for next activation.

Definition at line 785 of file scheduler.c.

◆ Lz_WaitTimer()

void Lz_WaitTimer ( lz_u_resolution_unit_t  units)

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

As Lazuli is a time sliced operating system, the effective waiting will start at the end of the current time slice. This means that the real waiting time starting from the calling of this function will be:

units / clock resolution frequency <= waiting time AND waiting time < (units + 1) / clock resolution frequency

See the configuration option LZ_CONFIG_SYSTEM_CLOCK_RESOLUTION_FREQUENCY.

Parameters
unitsThe number of time slices to wait.
Warning
Only works for tasks with PRIORITY_RT policy.

Definition at line 804 of file scheduler.c.