Lazuli
Functions | Variables
scheduler.h File Reference

Lazuli scheduler interface. More...

#include <stdint.h>
#include <Lazuli/common.h>
#include <Lazuli/lazuli.h>
#include <Lazuli/mutex.h>
#include <Lazuli/sys/task.h>

Go to the source code of this file.

Functions

void Scheduler_Init (void)
 Initialize the scheduler prior to running it. More...
 
void Scheduler_AbortTask (void *const sp)
 Call the appropriate scheduler to abort the curent running task. More...
 
void Scheduler_HandleInterrupt (const uint8_t interruptCode)
 This function is called by arch-specific interrupt handling routine. More...
 
void Scheduler_HandleClockTick (void *const sp)
 This function is called when a clock tick occured, catch by the interrupt handler. More...
 
void Scheduler_WaitEvent (void *const sp, const uint8_t eventCode)
 This function is called from arch-specific Wait routine in order to get the current running task wait for a particular event, after saving its context. More...
 
void Scheduler_WakeupTasksWaitingMutex (Lz_Mutex *const mutex)
 Wake up all tasks waiting for a mutex. More...
 
TaskScheduler_GetCurrentTask (void)
 Get a pointer to the current running task. More...
 
void Scheduler_SleepUntilEndOfTimeSlice (void)
 Put the current task to sleep until the end of its time slice.
 

Variables

void(*)(void) ReverseBytesOfFunctionPointer (void(*const pointer)(void))
 Reverse the bytes of a function pointer. More...
 

Detailed Description

Lazuli scheduler interface.

The kernel API of the scheduler.

This file describes the kernel interface of the Lazuli scheduler.

Definition in file scheduler.h.

Function Documentation

◆ Scheduler_Init()

void Scheduler_Init ( void  )

Initialize the scheduler prior to running it.

This function is called by kernel initialization.

Definition at line 613 of file scheduler.c.

◆ Scheduler_AbortTask()

void Scheduler_AbortTask ( void *const  sp)

Call the appropriate scheduler to abort the curent running task.

Parameters
spThe stack pointer of the running task after saving its context.

Definition at line 632 of file scheduler.c.

◆ Scheduler_HandleInterrupt()

void Scheduler_HandleInterrupt ( const uint8_t  interruptCode)

This function is called by arch-specific interrupt handling routine.

This function is executed in the context of the current running task, i.e. on its stack.

Parameters
interruptCodeThe code of the interrupt being handled.

Definition at line 657 of file scheduler.c.

◆ Scheduler_HandleClockTick()

void Scheduler_HandleClockTick ( void *const  sp)

This function is called when a clock tick occured, catch by the interrupt handler.

Parameters
spThe stack pointer of the current running task after saving its context.

Definition at line 680 of file scheduler.c.

◆ Scheduler_WaitEvent()

void Scheduler_WaitEvent ( void *const  sp,
const uint8_t  eventCode 
)

This function is called from arch-specific Wait routine in order to get the current running task wait for a particular event, after saving its context.

Parameters
spThe stack pointer of the current running task after saving its context.
eventCodeThe code of the event the task is waiting for.

◆ Scheduler_WakeupTasksWaitingMutex()

void Scheduler_WakeupTasksWaitingMutex ( Lz_Mutex *const  mutex)

Wake up all tasks waiting for a mutex.

Parameters
mutexA pointer to the mutex the tasks are waiting for.

Definition at line 694 of file scheduler.c.

◆ Scheduler_GetCurrentTask()

Task* Scheduler_GetCurrentTask ( void  )

Get a pointer to the current running task.

Returns
A valid pointer to the current running task.

Definition at line 720 of file scheduler.c.

Variable Documentation

◆ ReverseBytesOfFunctionPointer

void(*)(void) ReverseBytesOfFunctionPointer(void(*const pointer)(void))

Reverse the bytes of a function pointer.

Parameters
pointerA function pointer.
Returns
A new function pointer from reversed bytes of parameter pointer.

Definition at line 35 of file scheduler.h.