I've just built and set up a vanilla Linux kernel with the RT patch applied. Everything went fine and I can now correctly boot into the new kernel.
What leaves me wondering is this: I have a simulator program that I've made in C, and I want it to execute in hard real time mode, as should be allowed by the new kernel. Probably the whole simulator doesn't need to be run with real-time priority, but some of the tasks inside do.
How can I accomplish this? I take it that simply running the program won't do.
If you are asking how to run some of the threads in real-time context, and others as conventional time-sharing threads, then all you need is to set their schedulers properly using
sched_setscheduler
.Time-sharing threads want to be
SCHED_OTHER
; real-time simulator threads want to beSCHED_FIFO
orSCHED_RR
.On Linux, in order to run at real-time priorities, your user must have resource limits (man 2 rlimit) that allows this. In particular, your
rtprio
rlimit must be set to the highest priority you will need. Alternatively, you can run the application as root. In a linux system with PAM, this is typically accomplished by adding the appropriate line to/etc/security/limits.conf
This will grant rtprio limits up to real-time priority 99 to the realtime group. Then you add a real-time group to
/etc/groups
and make sure your user is in the group.(And since this appears to be your first time doing this, you may also want to have a "dead man's switch" high-priority real-time thread around to make sure that your simulator doesn't get out of hand and render the system unusable... if you are simulating high CPU load, you may get ACTUAL high CPU load and be unable to stop things without a reboot.)