Tutorial: Leveraging the OS CPU Scheduler to Write Real-Time MT Apps
summary
Linux supports per-thread sched via pthread_setschedparam and syscalls to set POSIX policies (sched_fifo, SCHED_RR, SCHED_OTHER); real‑time priorities run 1–99 while normal threads have priority 0. Demo C program creates two threads, uses chrt/taskset/setcap (CAP_SYS_NICE) to assign sched_fifo priority 1-99 and CPU affinity so one thread preempts another; it works once affinity pins threads to the same core. Kernel tuning uses /proc/sys/kernel/sched_rt_runtime_us (default 950000/1000000) to leak CPU; PREEMPT_RT patches (e.g., for 6.1.19) cut max latency in cyclictest.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 2:14Defining real-time
- 7:01Gpos vs. Rtos
- 16:13Linux process model
- 30:46Kernel architecture
- 43:21Scheduling policies
- 1:00:17Practical scheduling tools
- 1:10:42Real-time programming demo
- 1:35:38System tuning
- 1:40:43Systemd integration
- 1:44:25Rtl and kernel preemption
related talks
47mReal-Time Linux: What Is Next?
38mFixing Real-Time Scheduler Throttling in the Linux Kernel
51mReal Time is Coming to Linux; What Does that Mean to You?
46mOptimizing Scheduler for Linux Gaming
52mEffectively Measure and Reduce Kernel Latencies for Real-time Constraints
44mReal-Time Linux on Embedded Multicore Processors
40mRT Linux in Safety-Critical Systems: The Potential and the Challenges
25mLinux needs a Scheduler QOS API -- and it isn't nice(2)
