RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
Data Structures | Functions | Variables
RT::OS Namespace Reference

Data Structures

class  xbuffFifo
 
class  Fifo
 
class  evlFifo
 
class  posixFifo
 
class  xenomaiFifo
 
struct  Task
 

Functions

int getFifo (std::unique_ptr< Fifo > &fifo, size_t fifo_size)
 
int initiate (RT::OS::Task *task)
 
void shutdown (RT::OS::Task *task)
 
void deleteTask (Task *task)
 
int setPeriod (Task *task, int64_t period)
 
int64_t getPeriod ()
 
void sleepTimestep (Task *task)
 
bool isRealtime ()
 
int64_t getTime ()
 
double getCpuUsage ()
 
int createTask (Task *task, void(*func)(void *), void *arg)
 
void renameOSThread (std::thread &thread, const std::string &name)
 

Variables

const int64_t SECONDS_TO_NANOSECONDS
 
const int64_t DEFAULT_PERIOD = 1000000
 
const uint64_t DEFAULT_FIFO_SIZE = 255
 
const size_t PROCESSOR_COUNT = std::thread::hardware_concurrency()
 

Function Documentation

◆ createTask()

int RT::OS::createTask(Tasktask,
void(*)(void *) func,
void * arg 
)

Creates a real-time task. This task will be associated with a system object to manage it.

Parameters
taskObject holding metadata for real-time task
entryCallable function that will run the real-time loop
argReference to RT::System object that will manage this real-time loop
Returns
0 if successful, -1 otherwise

Definition at line 86 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ deleteTask()

void RT::OS::deleteTask(Tasktask)

terminates task in real-time loop

Parameters
taskTask object holding metadata for real-time task
See also
RT::OS::createTask()

Definition at line 117 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ getCpuUsage()

double RT::OS::getCpuUsage()

Returns the percentage of Cpu being used by the Real-Time Thread. Should not be run from the real-time thread directly as this can cause high latency.

Returns
CPU_TIME Percentage of time the cpu is spent on real-time thread calculations. In multicore systems it is the percent of Cpu for the specific processor running the real-time task.

Definition at line 232 of file rt_os-xenomai.cpp.

Here is the call graph for this function:

◆ getFifo()

int RT::OS::getFifo(std::unique_ptr< Fifo > & fifo,
size_t fifo_size 
)

Obtain the Fifo object for this architecture.

The Object Returned is a Fifo object that holds an implementation specific fifo/pipe.

Parameters
fifoThe fifo object to store the newly created fifo.
fifo_sizeThe size of the fifo to create
Returns
0 if successful, and errno otherwise.

Definition at line 194 of file fifo.cpp.

◆ getPeriod()

int64_t RT::OS::getPeriod()

Get the period for the real-time task

This function can only be called from a real-time context and will not function from other threads that are not real-time. It is meant to provide the real-time period to Thread/Device classes that require this value for their calculations in the real-time loop. Available inside execute().

Returns
Period of the realtime thread the calling function is runninng from, -1 otherwise.
See also
RT::OS::sleepTimestep

Definition at line 150 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ getTime()

int64_t RT::OS::getTime(void )

Returns the current CPU time in nanoseconds. In general this is really only useful for determining the time between two events.

Returns
The current CPU time.

Definition at line 186 of file rt_os-xenomai.cpp.

◆ initiate()

int RT::OS::initiate(RT::OS::Tasktask)

Initializes the real-time resources. This is done by locking memory Pages and storing real-time identification variables

Parameters
taskThe real-time structure identifying the task
Returns
0 if successful, error code otherwise
See also
RT::OS::shutdown()

Definition at line 39 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ isRealtime()

bool RT::OS::isRealtime(void )

CHecks whether the calling thread is in real time. Important for functions that should not have access to real-time services else risk blocking the whole computer system.

Returns
true if the calling thread is real-time, false otherwise

Definition at line 179 of file rt_os-xenomai.cpp.

◆ renameOSThread()

void RT::OS::renameOSThread(std::thread & thread,
const std::string & name 
)

Renames a thread. This is useful for debugging and developer sanity

Parameters
threadStandard thread object
nameString holding the name to assign to thread

Definition at line 175 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ setPeriod()

int RT::OS::setPeriod(Tasktask,
int64_t period 
)

Set the period for the real-time task

Parameters
taskObject holding metadata for real-time task
periodThe new period to set the real-time loop to
Returns
0 if successful, -1 otherwise
See also
RT::OS::sleepTimestep

Definition at line 144 of file rtos_evl.cpp.

◆ shutdown()

void RT::OS::shutdown(RT::OS::Tasktask)

Releases real-time resources from the operating system. Called when rtxi is closing.

Parameters
taskthe real-time structure identifying the task
See also
RT::OS::initiate()

Definition at line 72 of file rtos_evl.cpp.

Here is the call graph for this function:

◆ sleepTimestep()

void RT::OS::sleepTimestep(Tasktask)

Uses real-time core to sleep until the next periodic wakeup. It uses the timestep given in task to determine next waekup.

Parameters
taskObject holding the timestep data for the task
See also
RT::OS::setPeriod()

Definition at line 159 of file rtos_evl.cpp.

Here is the call graph for this function:

Variable Documentation

◆ DEFAULT_FIFO_SIZE

const uint64_t RT::OS::DEFAULT_FIFO_SIZE = 255

Definition at line 20 of file rtos.hpp.

◆ DEFAULT_PERIOD

const int64_t RT::OS::DEFAULT_PERIOD = 1000000

Definition at line 19 of file rtos.hpp.

◆ PROCESSOR_COUNT

const size_t RT::OS::PROCESSOR_COUNT = std::thread::hardware_concurrency()

Definition at line 21 of file rtos.hpp.

◆ SECONDS_TO_NANOSECONDS

const int64_t RT::OS::SECONDS_TO_NANOSECONDS
Initial value:
=
1000000000

Definition at line 17 of file rtos.hpp.