RT setup

you need a kernel with low-latency patch.

To allow thread to change priority to rt, you need (choose one):

  1. to be root (buuuuuuuuurk)
  2. to use libpam
  3. to use realtime-lsm (linux security module) (DEPRECATED)


  • set thread in rt:
result = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
result = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
  • set priority on a thread: (sample from jack)
struct sched_param rtparam;
int x;
memset (&rtparam, 0, sizeof (rtparam));
rtparam.sched_priority = priority;
if ((x = pthread_setschedparam (thread, SCHED_FIFO, &rtparam)) != 0)
  return -1;
  • usefull function to configure thread:
//autostart the thread

//inherit attr for the thread from parent

//set the thread type and it's priority
//priority only for FIFO or RR

//set the thread type (round robin, fifo, sporadic, etc...)
//SCHED_FIFO (only blocking function or preemption from higher priority thread can stop the current thread)
//SCHED_RR (same as fifo, but the thread only run for one time quantum)
//SCHED_OTHER (tout pourri algorithme inside)
//SCHED_SPORADIC (there is a minimal time between to activation of the task (periodic task are sporadic with inter-arrival)

//set the scope (system or process)

//configure the stack
realtime.txt · Last modified: 2008/03/20 01:06 by ctaf
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki