pid
Files | Classes | Enumerations | Functions
pid-realtime: controlling realtime properties of executables

realtime library eases to monitor and control the execution of real-time threads. More...

Files

file  real_time.h
 header for the the real time library
 

Classes

class  pid::MemoryLocker
 Avoids the process memory to be swapped out as long as the object is alive. More...
 
class  pid::CurrentThreadElapsedCPUTime
 Counts real time spent by current thread on a CPU. More...
 

Enumerations

enum  pid::NormalSchedulingPolicy { pid::NormalSchedulingPolicy::Other, pid::NormalSchedulingPolicy::Idle, pid::NormalSchedulingPolicy::Batch }
 Available non realtime sheduling policy. More...
 
enum  pid::RealTimeSchedulingPolicy { pid::RealTimeSchedulingPolicy::FIFO, pid::RealTimeSchedulingPolicy::RoundRobin }
 Available realtime sheduling policy. More...
 

Functions

void pid::set_thread_affinity (std::thread &thread, int cpu)
 Forces a thread to be executed on the given CPU/core. More...
 
void pid::setThreadAffinity (std::thread &thread, int cpu)
 Forces a thread to be executed on the given CPU/core. More...
 
void pid::set_thread_affinity (std::thread::native_handle_type thread, int cpu)
 Forces a thread to be executed on the given CPU/core. More...
 
void pid::setThreadAffinity (std::thread::native_handle_type thread, int cpu)
 Forces a thread to be executed on the given CPU/core. More...
 
void pid::set_current_thread_affinity (int cpu)
 Forces the current thread to be executed on the given CPU/core. More...
 
void pid::setCurrentThreadAffinity (int cpu)
 Forces the current thread to be executed on the given CPU/core. More...
 
void pid::set_thread_scheduler (std::thread &thread, NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for current thread. More...
 
void pid::setThreadScheduler (std::thread &thread, NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for current thread. More...
 
void pid::set_thread_scheduler (std::thread::native_handle_type thread, NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for a given thread. More...
 
void pid::setThreadScheduler (std::thread::native_handle_type thread, NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for a given thread. More...
 
void pid::set_current_thread_scheduler (NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for the current thread. More...
 
void pid::setCurrentThreadScheduler (NormalSchedulingPolicy policy)
 Sets a non-realtime scheduling policy for the current thread. More...
 
void pid::set_thread_scheduler (std::thread &thread, RealTimeSchedulingPolicy policy, int priority)
 Sets a realtime scheduling policy for a given thread. More...
 
void pid::setThreadScheduler (std::thread &thread, RealTimeSchedulingPolicy policy, int priority)
 Sets a realtime scheduling policy for a given thread. More...
 
void pid::set_thread_scheduler (std::thread::native_handle_type thread, RealTimeSchedulingPolicy policy, int priority)
 Sets a realtime scheduling policy for a given thread. More...
 
void pid::setThreadScheduler (std::thread::native_handle_type thread, RealTimeSchedulingPolicy policy, int priority)
 Sets a realtime scheduling policy for a given thread. More...
 
void pid::set_current_thread_scheduler (RealTimeSchedulingPolicy policy, int priority)
 Sets a realtime scheduling policy for the current thread. More...
 
std::shared_ptr< MemoryLockerpid::make_thread_real_time (std::thread &thread, int priority=90, int cpu_idx=-1)
 Sets some default parameters to the given thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler. More...
 
std::shared_ptr< MemoryLockerpid::makeThreadRealTime (std::thread &thread, int priority=90, int cpu_idx=-1)
 Sets some default parameters to the given thread to make it real time. More...
 
std::shared_ptr< MemoryLockerpid::make_thread_real_time (std::thread::native_handle_type thread, int priority=90, int cpu_idx=-1)
 Sets some default parameters to the given thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler. More...
 
std::shared_ptr< MemoryLockerpid::makeThreadRealTime (std::thread::native_handle_type thread, int priority=90, int cpu_idx=-1)
 Sets some default parameters to the given thread to make it real time. More...
 
std::shared_ptr< MemoryLockerpid::make_current_thread_real_time (int priority=90, int cpu_idx=-1)
 Sets some default parameters to the current thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler. More...
 
std::shared_ptr< MemoryLockerpid::makeCurrentThreadRealTime (int priority=90, int cpu_idx=-1)
 Sets some default parameters to the current thread to make it real time. More...
 

Detailed Description

realtime library eases to monitor and control the execution of real-time threads.

General functionalities provided are:

Enumeration Type Documentation

◆ NormalSchedulingPolicy

Available non realtime sheduling policy.

Enumerator
Other 
Idle 
Batch 

◆ RealTimeSchedulingPolicy

Available realtime sheduling policy.

Enumerator
FIFO 
RoundRobin 

Function Documentation

◆ make_current_thread_real_time()

std::shared_ptr<MemoryLocker> pid::make_current_thread_real_time ( int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the current thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler.

The scheduling policy is RealTimeSchedulingPolicy::FIFO. At each function call a new CPU is used to pin the thread to, unless all CPUs have been used already and it that case it starts again from the first one. The MemoryLocker is default-created.

Parameters
priority(optional) the priority to give to the thread, in the 1-99 range
cpu_idx(optional) the index of the cpu the thread will execute on
Returns
std::shared_ptr<MemoryLocker> a MemoryLocker shared_ptr object to keep alive for the thread lifetile
Examples
ex_realtime.cpp.

◆ make_thread_real_time() [1/2]

std::shared_ptr<MemoryLocker> pid::make_thread_real_time ( std::thread &  thread,
int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the given thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler.

The scheduling policy is RealTimeSchedulingPolicy::FIFO. At each function call a new CPU is used to pin the thread to, unless all CPUs have been used already and it that case it starts again from the first one. The MemoryLocker is default-created.

Parameters
threadthe thread that requires real time capabilities
priority(optional) the priority to give to the thread, in the 1-99 range
cpu_idx(optional) the index of the cpu the thread will execute on
Returns
std::shared_ptr<MemoryLocker> a MemoryLocker shared_ptr object to keep alive for the thread lifetile
Examples
ex_realtime.cpp.

◆ make_thread_real_time() [2/2]

std::shared_ptr<MemoryLocker> pid::make_thread_real_time ( std::thread::native_handle_type  thread,
int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the given thread to make it real time. For a finer control, please use setThreadAffinity and setThreadScheduler.

The scheduling policy is RealTimeSchedulingPolicy::FIFO. At each function call a new CPU is used to pin the thread to, unless all CPUs have been used already and it that case it starts again from the first one. The MemoryLocker is default-created.

Parameters
threadthe thread that requires real time capabilities
priority(optional) the priority to give to the thread, in the 1-99 range
cpu_idx(optional) the index of the cpu the thread will execute on
Returns
std::shared_ptr<MemoryLocker> a MemoryLocker shared_ptr object to keep alive for the thread lifetile

◆ makeCurrentThreadRealTime()

std::shared_ptr<MemoryLocker> pid::makeCurrentThreadRealTime ( int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the current thread to make it real time.

Deprecated:
now replaced by make_current_thread_real_time
See also
make_current_thread_real_time

◆ makeThreadRealTime() [1/2]

std::shared_ptr<MemoryLocker> pid::makeThreadRealTime ( std::thread &  thread,
int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the given thread to make it real time.

Deprecated:
now replaced by make_thread_real_time
See also
make_thread_real_time

◆ makeThreadRealTime() [2/2]

std::shared_ptr<MemoryLocker> pid::makeThreadRealTime ( std::thread::native_handle_type  thread,
int  priority = 90,
int  cpu_idx = -1 
)

Sets some default parameters to the given thread to make it real time.

Deprecated:
now replaced by make_thread_real_time
See also
make_thread_real_time

◆ set_current_thread_affinity()

void pid::set_current_thread_affinity ( int  cpu)

Forces the current thread to be executed on the given CPU/core.

Parameters
cputhe cpu to pin the thread to
Examples
ex_realtime.cpp.

◆ set_current_thread_scheduler() [1/2]

void pid::set_current_thread_scheduler ( NormalSchedulingPolicy  policy)

Sets a non-realtime scheduling policy for the current thread.

Parameters
policythe scheduling policy to use

◆ set_current_thread_scheduler() [2/2]

void pid::set_current_thread_scheduler ( RealTimeSchedulingPolicy  policy,
int  priority 
)

Sets a realtime scheduling policy for the current thread.

Parameters
policythe scheduling policy to use
prioritythe scheduling priority to use, in the 1-99 range

◆ set_thread_affinity() [1/2]

void pid::set_thread_affinity ( std::thread &  thread,
int  cpu 
)

Forces a thread to be executed on the given CPU/core.

Parameters
threadthe thread to set the affinity to
cputhe cpu to pin the thread to

◆ set_thread_affinity() [2/2]

void pid::set_thread_affinity ( std::thread::native_handle_type  thread,
int  cpu 
)

Forces a thread to be executed on the given CPU/core.

Parameters
threadthe thread to set the affinity to
cputhe cpu to pin the thread to

◆ set_thread_scheduler() [1/4]

void pid::set_thread_scheduler ( std::thread &  thread,
NormalSchedulingPolicy  policy 
)

Sets a non-realtime scheduling policy for current thread.

Parameters
threadthe thread to set the scheduling policy for
policythe scheduling policy to use

◆ set_thread_scheduler() [2/4]

void pid::set_thread_scheduler ( std::thread &  thread,
RealTimeSchedulingPolicy  policy,
int  priority 
)

Sets a realtime scheduling policy for a given thread.

Parameters
threadthe thread to set the scheduling policy for
policythe scheduling policy to use
prioritythe scheduling priority to use, in the 1-99 range

◆ set_thread_scheduler() [3/4]

void pid::set_thread_scheduler ( std::thread::native_handle_type  thread,
NormalSchedulingPolicy  policy 
)

Sets a non-realtime scheduling policy for a given thread.

Parameters
threadthe thread to set the scheduling policy for
policythe scheduling policy to use

◆ set_thread_scheduler() [4/4]

void pid::set_thread_scheduler ( std::thread::native_handle_type  thread,
RealTimeSchedulingPolicy  policy,
int  priority 
)

Sets a realtime scheduling policy for a given thread.

Parameters
threadthe thread to set the scheduling policy for
policythe scheduling policy to use
prioritythe scheduling priority to use, in the 1-99 range

◆ setCurrentThreadAffinity()

void pid::setCurrentThreadAffinity ( int  cpu)

Forces the current thread to be executed on the given CPU/core.

Deprecated:
now replaced by set_current_thread_affinity
See also
set_current_thread_affinity

◆ setCurrentThreadScheduler()

void pid::setCurrentThreadScheduler ( NormalSchedulingPolicy  policy)

Sets a non-realtime scheduling policy for the current thread.

Deprecated:
now replaced by set_current_thread_scheduler
See also
set_current_thread_scheduler

◆ setThreadAffinity() [1/2]

void pid::setThreadAffinity ( std::thread &  thread,
int  cpu 
)

Forces a thread to be executed on the given CPU/core.

Deprecated:
now replaced by set_thread_affinity
See also
set_thread_affinity

◆ setThreadAffinity() [2/2]

void pid::setThreadAffinity ( std::thread::native_handle_type  thread,
int  cpu 
)

Forces a thread to be executed on the given CPU/core.

Deprecated:
now replaced by set_thread_affinity
See also
set_thread_affinity

◆ setThreadScheduler() [1/4]

void pid::setThreadScheduler ( std::thread &  thread,
NormalSchedulingPolicy  policy 
)

Sets a non-realtime scheduling policy for current thread.

Deprecated:
now replaced by set_thread_scheduler
See also
set_thread_scheduler

◆ setThreadScheduler() [2/4]

void pid::setThreadScheduler ( std::thread &  thread,
RealTimeSchedulingPolicy  policy,
int  priority 
)

Sets a realtime scheduling policy for a given thread.

Deprecated:
now replaced by set_thread_scheduler
See also
set_thread_scheduler

◆ setThreadScheduler() [3/4]

void pid::setThreadScheduler ( std::thread::native_handle_type  thread,
NormalSchedulingPolicy  policy 
)

Sets a non-realtime scheduling policy for a given thread.

Deprecated:
now replaced by set_thread_scheduler
See also
set_thread_scheduler

◆ setThreadScheduler() [4/4]

void pid::setThreadScheduler ( std::thread::native_handle_type  thread,
RealTimeSchedulingPolicy  policy,
int  priority 
)

Sets a realtime scheduling policy for a given thread.

Deprecated:
now replaced by set_thread_scheduler
See also
set_thread_scheduler