CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
task.h File Reference

Minimal FreeRTOS task compatibility APIs. More...

#include "FreeRTOS.h"
#include "thread.h"
#include <locks.h>

Go to the source code of this file.

Macros

#define INC_TASK_H
#define xTaskCreate(...)
 Task creation API.
#define xTaskCreateStatic(...)
 Task creation API.

Functions

static void vTaskSetTimeOutState (TimeOut_t *timeout)
 Initialise a timeout with the current number of elapsed ticks.
static BaseType_t xTaskCheckForTimeOut (TimeOut_t *pxTimeOut, TickType_t *pxTicksToWait)
 Return whether a timeout has expired.
static void vTaskDelay (const TickType_t xTicksToDelay)
 Block the current thread for a given number of ticks.
static TickType_t xTaskGetTickCount (void)
 Return the number of ticks elapsed since the system booted.
static TaskHandle_t xTaskGetCurrentTaskHandle (void)
 Returns the current thread ID.
static void taskENTER_CRITICAL (void)
 Critical section.
static void taskEXIT_CRITICAL (void)
 Exit a critical section entered with taskENTER_CRITICAL.
static void vTaskSuspendAll (void)
 Critical section.
static BaseType_t xTaskResumeAll (void)
 Exit a critical section entered with vTaskSuspendAll.
static void vTaskResumeAll (void)
 Exit a critical section entered with vTaskSuspendAll.

Variables

struct RecursiveMutexState __CriticalSectionFlagLock
 Lock used to simulate disabling interrupts in taskENTER_CRITICAL and taskEXIT_CRITICAL.
struct RecursiveMutexState __SuspendFlagLock
 Lock used to simulate disabling interrupts in vTaskSuspendAll and xTaskResumeAll.

Detailed Description

Minimal FreeRTOS task compatibility APIs.

This file defines the compatibility wrappers for FreeRTOS's task APIs.

FreeRTOS's task abstraction is similar to a UNIX process and does not map directly to a CHERIoT RTOS concept. CHERIoT RTOS also does not support dynamic thread creation and so the task-creation APIs are defined to give compile-time errors.

Definition in file task.h.

Macro Definition Documentation

◆ INC_TASK_H

#define INC_TASK_H

Definition at line 5 of file task.h.

◆ xTaskCreate

#define xTaskCreate ( ...)
Value:
_Pragma("GCC warning \"Dynamic thread creation is not supported\"")( \
1
uint16_t TaskHandle_t
FreeRTOS type representing a task handle, mapped to a thread ID in CHERIoT RTOS.
Definition FreeRTOS.h:188

Task creation API.

CHERIoT RTOS does not permit dynamic thread creation and so this simply provides a warning so that ported code can be modified to avoid the API.

Definition at line 166 of file task.h.

◆ xTaskCreateStatic

#define xTaskCreateStatic ( ...)
Value:
_Pragma("GCC warning \"Dynamic thread creation is not supported\"")( \
1

Task creation API.

CHERIoT RTOS does not permit dynamic thread creation and so this simply provides a warning so that ported code can be modified to avoid the API.

Definition at line 176 of file task.h.

Function Documentation

◆ taskENTER_CRITICAL()

void taskENTER_CRITICAL ( void )
inlinestatic

Critical section.

This acquires a recursive mutex. In FreeRTOS, this disables interrupts. The CHERIoT RTOS security model does not permit interrupts to be arbitrarily disabled, only for designated scopes. Callers of this should be carefully audited to ensure that they are safe.

Definition at line 118 of file task.h.

References __CriticalSectionFlagLock, recursivemutex_trylock(), and UnlimitedTimeout.

◆ taskEXIT_CRITICAL()

void taskEXIT_CRITICAL ( void )
inlinestatic

Exit a critical section entered with taskENTER_CRITICAL.

Definition at line 127 of file task.h.

References __CriticalSectionFlagLock, and recursivemutex_unlock().

◆ vTaskDelay()

void vTaskDelay ( const TickType_t xTicksToDelay)
inlinestatic

Block the current thread for a given number of ticks.

Definition at line 67 of file task.h.

References thread_sleep(), and ThreadSleepNoEarlyWake.

◆ vTaskResumeAll()

void vTaskResumeAll ( void )
inlinestatic

Exit a critical section entered with vTaskSuspendAll.

Definition at line 156 of file task.h.

References __SuspendFlagLock, and recursivemutex_unlock().

◆ vTaskSetTimeOutState()

void vTaskSetTimeOutState ( TimeOut_t * timeout)
inlinestatic

Initialise a timeout with the current number of elapsed ticks.

This is used in a blocking function in conjunction with xTaskCheckForTimeOut(). The value returned here should be passed as the first argument of xTaskCheckForTimeOut().

Definition at line 25 of file task.h.

References SystickReturn::hi, and SystickReturn::lo.

Referenced by xTaskCheckForTimeOut().

◆ vTaskSuspendAll()

void vTaskSuspendAll ( void )
inlinestatic

Critical section.

This acquires a recursive mutex. In FreeRTOS, this disables interrupts. The CHERIoT RTOS security model does not permit interrupts to be arbitrarily disabled, only for designated scopes. Callers of this should be carefully audited to ensure that they are safe.

Definition at line 138 of file task.h.

References __SuspendFlagLock, recursivemutex_trylock(), and UnlimitedTimeout.

◆ xTaskCheckForTimeOut()

BaseType_t xTaskCheckForTimeOut ( TimeOut_t * pxTimeOut,
TickType_t * pxTicksToWait )
inlinestatic

Return whether a timeout has expired.

The first argument should be a pointer to the value returned by vTaskSetTimeOutState() before any blocking operations. The second argument is the number of ticks to wait. This function returns pdTRUE if the timeout has expired, or pdFALSE if the timeout has not expired, and updates the arguments to reflect the remaining time to wait.

Definition at line 39 of file task.h.

References pdFALSE, pdTRUE, and vTaskSetTimeOutState().

◆ xTaskGetCurrentTaskHandle()

TaskHandle_t xTaskGetCurrentTaskHandle ( void )
inlinestatic

Returns the current thread ID.

Definition at line 89 of file task.h.

References thread_id_get().

◆ xTaskGetTickCount()

TickType_t xTaskGetTickCount ( void )
inlinestatic

Return the number of ticks elapsed since the system booted.

This is truncated to a 32-bit value.

Definition at line 81 of file task.h.

◆ xTaskResumeAll()

BaseType_t xTaskResumeAll ( void )
inlinestatic

Exit a critical section entered with vTaskSuspendAll.

Definition at line 147 of file task.h.

References __SuspendFlagLock, pdTRUE, and recursivemutex_unlock().

Variable Documentation

◆ __CriticalSectionFlagLock

struct RecursiveMutexState __CriticalSectionFlagLock
extern

Lock used to simulate disabling interrupts in taskENTER_CRITICAL and taskEXIT_CRITICAL.

Code using these APIs must provide a definition to accompany this declaration.

Referenced by taskENTER_CRITICAL(), and taskEXIT_CRITICAL().

◆ __SuspendFlagLock

struct RecursiveMutexState __SuspendFlagLock
extern

Lock used to simulate disabling interrupts in vTaskSuspendAll and xTaskResumeAll.

Code using these APIs must provide a definition to accompany this declaration.

Referenced by vTaskResumeAll(), vTaskSuspendAll(), and xTaskResumeAll().