RTUtility Class Reference

The RTUtility class contains functions for improving the realtime capabilities of a thread or of the whole system. More...

#include <armarx/control/ethercat/RTUtility.h>

Static Public Member Functions

static bool elevateThreadPriority (int priority)
 Elevate the thread priority of the calling thread to the given priority. More...
 
static bool pinThreadToCPU (unsigned int cpu)
 Pins the calling thread to the CPU with the given id. More...
 
static bool startLowLatencyMode ()
 Activate low latency mode of the system. More...
 
static bool stopLowLatencyMode ()
 Deactivate low latency mode of the system. More...
 

Static Public Attributes

static constexpr int RT_THREAD_PRIORITY = 49
 The thread priority for rt-threads. More...
 

Detailed Description

The RTUtility class contains functions for improving the realtime capabilities of a thread or of the whole system.

Definition at line 14 of file RTUtility.h.

Member Function Documentation

◆ elevateThreadPriority()

bool elevateThreadPriority ( int  priority)
static

Elevate the thread priority of the calling thread to the given priority.

The owning user of the calling thread must be allowed to set its priority to the given value. Each user has a maximum value it can sets its thread priorities to. This maximum value can be configured by editing the file /etc/security/limits.conf according to https://linux.die.net/man/5/limits.conf and setting the entry rtprio for the executing users. This function will only work if the operating system is build with a PRREMPT_RT patch (https://wiki.linuxfoundation.org/realtime/documentation/technical_details/start).

Parameters
prioritythe new priority of the calling thread
Returns
true if the requested priority could be set, false if not.

Definition at line 17 of file RTUtility.cpp.

+ Here is the caller graph for this function:

◆ pinThreadToCPU()

bool pinThreadToCPU ( unsigned int  cpu)
static

Pins the calling thread to the CPU with the given id.

The thread can only be pinned to a cpu which actually exists on the system.

Parameters
cpuThe id of the CPU the calling thread should be pinned to
Returns
tue if the pinning was successful, false if not

Definition at line 52 of file RTUtility.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startLowLatencyMode()

bool startLowLatencyMode ( )
static

Activate low latency mode of the system.

If the file /dev/cpu_dma_latency exists, open it and write a zero into it. This will tell the power management system not to transition to a high cstate (in fact, the system acts like idle=poll). When the fd to /dev/cpu_dma_latency is closed, the behavior goes back to the system default.

Taken from https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/rt-tests.

Returns
true if the low latency mode could be activated, false if not.

Definition at line 95 of file RTUtility.cpp.

◆ stopLowLatencyMode()

bool stopLowLatencyMode ( )
static

Deactivate low latency mode of the system.

Returns
true if low latency mode was active, false if not and nothng needs to be done

Definition at line 131 of file RTUtility.cpp.

Member Data Documentation

◆ RT_THREAD_PRIORITY

constexpr int RT_THREAD_PRIORITY = 49
staticconstexpr

The thread priority for rt-threads.

49 is the highest value that can be safely used, because PRREMPT_RT uses 50 for kernel tasklets and interrupt handler by default.

Definition at line 24 of file RTUtility.h.


The documentation for this class was generated from the following files: