Real-time programming with Linux

后端 未结 1 1749
忘了有多久
忘了有多久 2021-02-04 21:50

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 wonde

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 22:11

    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 be SCHED_FIFO or SCHED_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

        @realtime   -  rtprio     99

    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.)

    0 讨论(0)
提交回复
热议问题