CPU Affinity & Real-Time Operating Systems

Learn how CPU affinity changes task placement, how Linux real-time policies differ, and why deadline guarantees depend on workload, configuration, and hardware.

published: reading time: 24 min read author: Geek Workbench updated: November 8, 2026
Quick Summary

Learn how CPU affinity changes task placement, how Linux real-time policies differ, and why deadline guarantees depend on workload, configuration, and hardware.

CPU Affinity & Real-Time Operating Systems

Operating systems choose where and when runnable work executes. CPU affinity limits the cores a task may run on. Real-time scheduling policies change scheduling priorities and budgets. Neither setting alone guarantees that an application will meet every deadline; that depends on the workload, resource use, interrupts, kernel configuration, and hardware.

This post is part of the Operating Systems Roadmap — specifically Section 3.3 on Process and Thread Management. If you are new to scheduling concepts, start with Process Scheduling and Process Concept for the fundamentals.


Introduction

CPU affinity and real-time policies are useful when the timing behavior of a task matters. They are common in embedded control, signal processing, and other workloads with deadlines. Most services do not need hard real-time guarantees, and pinning a task can reduce scheduling flexibility or overload a selected core.

This post covers two related capabilities. CPU affinity limits a process or thread to eligible CPU cores. Affinity can reduce migration and help align a task with NUMA-local memory, but it does not reserve a core or prevent interrupts and other work from adding delay. Real-time scheduling policies change scheduling behavior; any timing bound still depends on a schedulable workload and the platform configuration.

Affinity is a separate decision from scheduler policy. Pinning can reduce migration, but it can also concentrate load or interfere with other tasks. Measure with and without affinity under representative system load before keeping it.

After this post, you will know how to pin processes to cores with sched_setaffinity and taskset, how SCHED_FIFO, SCHED_RR, and SCHED_DEADLINE differ and when to use each, what priority inversion is and how priority inheritance solves it, how PREEMPT_RT can reduce some Linux scheduling latency for soft real-time workloads, and how FreeRTOS, VxWorks, Zephyr, and QNX compare for different embedded contexts.

This is Section 3.3 of the Operating Systems Roadmap. If you are coming from the scheduling algorithms post, you already know how the scheduler picks which runnable process gets CPU time. Here we cover how to override those decisions and control where and how long your work runs.

CPU Affinity: Taking Control of Placement

CPU affinity is a property that lets you bind a process or thread to a specific subset of CPU cores. When you set affinity, the scheduler respects your preference — it will only place your work on the cores you specify.

The Linux API

Linux exposes affinity through a straightforward API built around bitmasks. Each bit in the mask corresponds to a logical CPU. If bit 3 is set, the process is eligible to run on core 3.

#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    cpu_set_t cpuset;
    pid_t pid = getpid();

    /* Clear the mask — start fresh */
    CPU_ZERO(&cpuset);

    /* Set bits for cores 0 and 2 */
    CPU_SET(0, &cpuset);
    CPU_SET(2, &cpuset);

    /* Apply the mask to the current process */
    if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpuset) == -1) {
        perror("sched_setaffinity");
        exit(EXIT_FAILURE);
    }

    /* Read it back to confirm */
    if (sched_getaffinity(pid, sizeof(cpu_set_t), &cpuset) == -1) {
        perror("sched_getaffinity");
        exit(EXIT_FAILURE);
    }

    printf("Running on cores: ");
    for (int i = 0; i < CPU_SETSIZE; i++) {
        if (CPU_ISSET(i, &cpuset))
            printf("%d ", i);
    }
    printf("\n");

    return 0;
}

CPU_SETSIZE is typically 1024, meaning you can address up to 1024 logical CPUs. CPU_ZERO, CPU_SET, CPU_CLR, and CPU_ISSET are the basic operations on these masks.

The shell command taskset wraps this API for convenient command-line use:

# Run a process exclusively on cores 0 and 2
taskset -c 0,2 ./my_real_time_app

# Launch on core 0 with exclusive affinity
taskset -c 0 ./latency_sensitive_worker

# Check the affinity of a running process
taskset -p $(pgrep -f my_real_time_app)

The -c flag accepts a comma-separated list or range. taskset -c 0-3 binds to cores 0 through 3.

Why Bind to Specific Cores?

The default scheduler balances runnable work across eligible CPUs. Affinity restricts that set, which can help a workload with a specific placement need but may reduce overall scheduling flexibility.

Cache locality can improve when a task stays on a core, but the benefit depends on its working set and competing work. Affinity reduces one source of migration; it does not eliminate cache misses or other scheduling delay.

NUMA systems amplify this concern. On a multi-socket server, memory access latency depends on which socket the CPU belongs to. Binding a process near its memory can reduce remote NUMA access, but verify placement and memory policy on the target machine.

Isolation requires more than setting process affinity. CPU sets, IRQ routing, kernel housekeeping, SMT siblings, and other workloads can still affect a core. Configure and test the complete platform before treating a CPU as isolated.

Affinity is not a latency guarantee. A pinned task can still be delayed by interrupts, higher-priority work, locks, memory faults, or hardware activity.

Soft Affinity vs Hard Affinity

Linux schedulers may preserve a task’s recent CPU placement by preference, while an explicit affinity mask restricts the CPUs on which it may run.

Soft affinity (also called natural affinity) is what the scheduler applies by default — a preference for keeping a process on the same core where it ran previously. This is a hint, not a requirement. The scheduler will migrate the process if needed, for example when a core becomes overcommitted.

Hard affinity is what you get when you explicitly call sched_setaffinity. An explicit affinity mask restricts the task to eligible CPUs. The allowed set is also constrained by cpusets and system policy.

You can combine these. A thread can have hard affinity for a subset of cores while the scheduler within that subset applies soft affinity to keep the thread on one particular core as much as possible.


Real-Time Scheduling Policies

Standard process scheduling in Linux is designed for throughput and fairness. The Completely Fair Scheduler (CFS) allocates CPU time to maximize aggregate work done, not to meet deadlines. For workloads where meeting a deadline is more important than throughput, Linux provides real-time scheduling policies.

SCHED_FIFO

SCHED_FIFO is the simplest real-time policy. Processes under this policy have no time slice — they run until they voluntarily yield or block. When a SCHED_FIFO process becomes runnable, it immediately preempts any lower-priority process.

Priority levels range from 1 to 99, with 99 being the highest. Only root can set priorities above 0.

struct sched_param sp = { .sched_priority = 90 };

if (sched_setscheduler(0, SCHED_FIFO, &sp) == -1) {
    perror("sched_setscheduler");
}

With SCHED_FIFO, if two processes at the same priority are both runnable, the one that has been waiting longer runs first — a simple FIFO queue. There is no time slicing whatsoever. A misbehaving SCHED_FIFO process that never yields will lock out all other processes at that priority level or lower.

SCHED_RR

SCHED_RR is identical to SCHED_FIFO except that processes at the same priority level share CPU time through round-robin rotation. Each process gets a fixed time quantum before the scheduler rotates to the next process at that priority.

This prevents a single SCHED_FIFO process from monopolizing a priority level, but it introduces a small amount of scheduling latency — the time between when a process exhausts its quantum and when it runs again is bounded by the number of same-priority runnable processes times the quantum duration.

SCHED_DEADLINE

SCHED_DEADLINE is the most sophisticated real-time policy, introduced in Linux 3.14. It implements the Earliest Deadline First (EDF) algorithm with bandwidth reservation.

Each task specifies:

  • Runtime — the maximum CPU time it needs per period
  • Deadline — the time by which it must complete
  • Period — the interval between successive invocations
struct sched_attr {
    __u32 size;
    __u32 sched_policy;
    __u64 sched_flags;
    __s64 sched_runtime;   /* nanoseconds */
    __u64 sched_deadline;  /* nanoseconds */
    __u64 sched_period;    /* nanoseconds */
};

struct sched_attr attr = {
    .size = sizeof(attr),
    .sched_policy = SCHED_DEADLINE,
    .sched_runtime = 10 * 1000 * 1000,  /* 10 ms */
    .sched_deadline = 20 * 1000 * 1000, /* 20 ms */
    .sched_period = 50 * 1000 * 1000,    /* 50 ms */
};

if (sched_setattr(0, &attr, 0) == -1) {
    perror("sched_setattr");
}

The kernel applies admission control to deadline reservations, but this is not an unconditional application-level guarantee. The workload must stay within its runtime assumptions, and system activity, locking, interrupts, CPU topology, kernel configuration, and hardware must be included in the analysis. See the Linux SCHED_DEADLINE documentation for its model and constraints.

Comparing Scheduling Policies

Policy Time Slicing Priority Range Deadline Support Use Case
SCHED_OTHER (CFS) Yes, fair share 0 only No General computing
SCHED_FIFO No 1-99 No Highest priority, non-preemptible
SCHED_RR Yes, fixed quantum 1-99 No Shared priority real-time tasks
SCHED_DEADLINE Runtime/period reservation EDF parameters, not a fixed priority range Yes, subject to admission and workload assumptions Periodic or sporadic deadline tasks

The Priority Inversion Problem

Illustrative priority inversion: a high-priority task waits for a lock held by a low-priority task, while medium-priority work keeps preempting the lock holder. The delay can make the high-priority task miss its deadline.

This scenario has a name: priority inversion. A high-priority task is indirectly blocked by a medium-priority task, because the medium-priority task is preempting a low-priority task that holds a lock needed by the high-priority task.

The classic sequence:

  1. Low-priority task L acquires mutex M
  2. L is preempted by medium-priority task M
  3. High-priority task H starts, tries to acquire M, and blocks
  4. H waits while M runs
  5. H starves — deadline may be missed

The window of vulnerability is proportional to the duration that L holds M while M can preempt L. In the worst case, H never runs.


Priority Inheritance: The Solution

The kernel solves priority inversion through priority inheritance for mutexes. When a high-priority task blocks on a mutex held by a lower-priority task, the kernel temporarily raises the holding task’s priority to match that of the blocked task.

pthread_mutex_t mutex;
pthread_mutexattr_t attr;

pthread_mutexattr_init(&attr);
/* Request priority inheritance for the mutex */
pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);

pthread_mutex_init(&mutex, &attr);

With PTHREAD_PRIO_INHERIT, the mutex records the priority of the highest-priority waiter. When the owning thread releases the mutex, its priority is restored to its original level. This propagation is transitive — if the owning thread itself holds another mutex with a waiter of even higher priority, the inheritance chain extends.

Priority inheritance is local to the mutex. It does not permanently change thread priorities. The kernel applies it only for the duration of the lock acquisition.

Linux mutexes (futex-based) support priority inheritance when configured with PTHREAD_PRIO_INHERIT. Not all kernel mutex implementations do. When designing real-time systems, verify that all synchronization primitives use priority inheritance.


PREEMPT_RT: Making Stock Linux Real-Time Capable

A general-purpose Linux kernel is not configured to provide hard real-time guarantees. Preemption behavior depends on kernel configuration, drivers, hardware, and system activity; measure the target rather than relying on a generic latency figure.

The PREEMPT_RT work reduces non-preemptible sections and makes many interrupt handlers schedulable threads. Exact behavior depends on the kernel version and configuration.

Key transformations in PREEMPT_RT:

  • All interrupt handlers become threaded — they run as kernel threads rather than in hardirq context. This makes them preemptible.
  • Spinlocks become sleeping locks, allowing the holder to be preempted.
  • Critical sections that cannot tolerate preemption are isolated and minimized.
  • The kernel’s internal locking uses priority inheritance everywhere.

These changes can reduce and help measure scheduling latency. They do not, by themselves, prove a hard worst-case bound for an application.

To use PREEMPT_RT, select a supported kernel and distribution release for your target. Availability, configuration, and support policy vary by distribution and kernel version.

For an initial measurement, use cyclictest from rt-tests and repeat under representative background load:

# Measure scheduling latency on all cores
cyclictest -l 1000000 -m -S -p 90

# Measure latency with per-thread histogram
cyclictest -l 1000000 -m -h 40 -q

Run the measurement under the same CPU, IRQ, memory, and I/O load that the application will see. The result describes that test run; it is not a guaranteed worst-case bound.


Where available, Linux rtla timerlat can report timer wake-up latency. For example, run a one-minute sample on selected CPUs while a representative workload is active:

sudo rtla timerlat top --cpus 0-3 --duration 1m

Check the installed rtla help because options depend on the kernel tools version. The kernel rtla timerlat documentation describes the tracer and its options. Record the kernel version, CPU set, workload, and observed maximum; repeat for each relevant operating condition.

Real-Time Operating Systems: Scheduling Is Only One Part of the Guarantee

A real-time OS can provide scheduling mechanisms needed for deadline analysis, but deadline success still depends on a feasible workload and controlled platform. Hard real-time systems treat a missed deadline as a system failure; soft real-time systems may tolerate some misses with degraded quality. Certification and timing evidence apply to a specific product edition, configuration, board, and application.

RTOS behavior depends on product version and configuration

These summaries point to public vendor documentation reviewed on November 8, 2026. They are not benchmark results. Scheduler behavior, available policies, certification evidence, and timing characteristics depend on the exact RTOS release, board support package, configuration, hardware, drivers, and workload. Use the documentation for the release and target you plan to ship.

RTOS and documentation scope Scheduling notes Reference
FreeRTOS kernel scheduling docs, current page updated October 2026 The documented default is fixed-priority preemptive scheduling with round-robin time slicing for equal priorities; configuration changes behavior. FreeRTOS task scheduling
VxWorks 7 product family; edition and release vary Wind River describes VxWorks as a real-time platform. Check the selected release, BSP, and certification package for scheduler and timing evidence. Wind River VxWorks documentation
Zephyr 4.5.0, latest stable release dated October 28, 2026 Priority-based scheduling; optional features and ready-queue implementation depend on configuration. Zephyr scheduling, release list
QNX Neutrino 8.0 documentation Documented scheduling algorithms include FIFO, round-robin, and sporadic; timing analysis must include the target and application. QNX real-time overview, scheduling policies

Do not compare RTOS products from headline latency numbers. Ask which release, board, CPU, build configuration, interrupt load, and measurement method produced the figure, then reproduce the measurement on the target system. A certification applies to a defined scope; it does not certify an arbitrary application built on the RTOS.

Scheduling Hierarchy: A Visual Map

Understanding how these concepts relate helps frame the design decisions. The following diagram maps the landscape from bare hardware through kernel scheduling to real-time policies.

graph TD
    Hardware["Hardware<br/>CPU Cores"]
    Kernel["Linux Kernel"]
    Scheduler["Scheduler"]
    CFS["CFS<br/>SCHED_OTHER"]
    RT["Real-Time Policies<br/>SCHED_FIFO · SCHED_RR · SCHED_DEADLINE"]
    Affinity["CPU Affinity API<br/>sched_setaffinity · taskset"]
    Preempt["PREEMPT_RT Patch"]
    RTOS["Dedicated RTOS<br/>FreeRTOS · VxWorks · Zephyr · QNX"]

    Hardware --> Kernel
    Kernel --> Scheduler
    Scheduler --> CFS
    Scheduler --> RT
    Scheduler --> Affinity
    Affinity --> Preempt
    Scheduler --> Preempt
    Kernel --> RTOS

    CFS -.->|"Best effort<br/>No latency guarantee"| CFS_label["Throughput-optimized"]
    RT -.->|"Priority/budget rules<br/>Under stated assumptions"| RT_label["Deadline workloads"]
    Affinity -.->|"Restricts eligible CPUs<br/>Does not guarantee latency"| Affinity_label["Placement control"]

Where Deadline Analysis Matters

Workload Timing question
Industrial control Can the control task finish before its next update when sensors, actuators, and diagnostics are active?
Medical or safety-related devices What is the safe behavior if a deadline is missed, and what evidence is required for the exact product and jurisdiction?
Audio or signal processing Can the processing callback complete before the next buffer is needed under representative system load?
Network or trading systems Which part of the end-to-end path has a measurable latency objective, and what is outside the scheduler’s control?

These are prompts for workload analysis, not claims that a particular RTOS or affinity setting meets a deadline. Define a deadline-miss condition, test the system under expected and worst-case load, and include a failure response.

Quick Recap Checklist

  • CPU affinity binds a process to specific cores via sched_setaffinity or taskset
  • Soft affinity is a scheduler preference; hard affinity is a strict mask
  • Affinity restricts eligible CPUs; NUMA locality and isolation need separate configuration and measurement
  • SCHED_FIFO has no time slicing — runs until yield or block
  • SCHED_RR adds round-robin rotation at the same priority level
  • SCHED_DEADLINE uses EDF with runtime/deadline/period parameters, subject to admission and workload assumptions
  • Priority inversion: H blocked by L, M preempts L → H starves
  • Priority inheritance: L’s priority temporarily raised to unblock H
  • PREEMPT_RT changes preemption and interrupt handling; verify behavior and latency on the target kernel
  • FreeRTOS, VxWorks, Zephyr, QNX are purpose-built RTOS options
  • cyclictest measures scheduling latency on PREEMPT_RT systems

Interview Questions

1. What is the difference between soft affinity and hard affinity in Linux?

Soft affinity is a preference that the scheduler applies naturally — the kernel tries to keep a process on the same core where it last ran, but will migrate it if necessary for load balancing or core availability. Hard affinity is an explicit mask set via sched_setaffinity or taskset that the scheduler must respect. With hard affinity, the process will never run on a core outside the specified mask.

2. What is priority inversion and how does priority inheritance solve it?

Priority inversion occurs when a high-priority task is blocked waiting for a resource held by a low-priority task, while a medium-priority task preempts the low-priority one and runs instead — effectively starving the high-priority task. Priority inheritance temporarily raises the holding task's priority to match the blocked task's priority, ensuring it runs and releases the lock quickly. The kernel restores the original priority once the lock is released.

3. Explain the difference between SCHED_FIFO, SCHED_RR, and SCHED_DEADLINE.

SCHED_FIFO has no time slicing — a runnable process runs until it voluntarily yields or blocks. SCHED_RR is identical but rotates among same-priority processes using a fixed time quantum. SCHED_DEADLINE uses Earliest Deadline First with bandwidth reservation — each task declares a runtime, deadline, and period, and the kernel guarantees the deadline provided total reserved bandwidth does not exceed CPU capacity.

4. What does the PREEMPT_RT patch set do to the Linux kernel?

PREEMPT_RT changes kernel preemption and interrupt handling to reduce sources of scheduling delay. Behavior and measured latency depend on the kernel release, configuration, hardware, drivers, and workload. Use `cyclictest` or `rtla timerlat` under representative load; the sample maximum is not a proof of worst-case latency.

5. When would you choose a dedicated RTOS like FreeRTOS over a PREEMPT_RT Linux system?

Compare a dedicated RTOS and PREEMPT_RT Linux against the target board, required scheduling model, driver support, development tools, maintenance plan, and evidence required for the product. Certification and timing claims apply only to the specific RTOS edition, release, configuration, board, and application scope. Measure the complete system; do not infer a bound from the product category.

6. What is the difference between soft affinity and hard affinity?

Soft affinity (also called natural affinity) is a preference — the scheduler tries to keep a process on the same CPU but can migrate it when needed (e.g., load balancing). Hard affinity is a mandatory constraint — you pin a process to a specific set of cores using sched_setaffinity(), and the kernel will never migrate it outside that set unless you explicitly remove the constraint. Hard affinity is used in real-time and performance-critical workloads where cache eviction cost matters more than load balancing.

7. How does NUMA awareness interact with CPU affinity?

NUMA memory access costs depend on the processor, memory topology, and access pattern. CPU affinity constrains where a task runs; memory policy controls where its pages are allocated. Use tools such as numactl or libnuma only when measurements show a locality issue, and verify both CPU and memory placement on the target system.

8. What is the relationship between CPU affinity and cache coherence?

Cache coherence protocols keep shared cache lines consistent across cores, but migration does not mean every cache line is invalidated or transferred. The impact depends on the working set, cache topology, sharing, and competing tasks. Compare cache misses and application latency with performance counters on the target machine before attributing a change to affinity.

9. Describe the behavior of sched_setaffinity() and its flags.

sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask) sets the CPU affinity mask for a process. Key macros: CPU_SETSIZE limits the mask to 1024 CPUs. CPU_ZERO clears a mask. CPU_SET/CPU_CLR add/remove individual cores. CPU_COUNT returns the number of set bits. The call returns 0 on success. Reading affinity back uses sched_getaffinity(). Use the API from normal thread context and check for errors; do not assume it is safe in an asynchronous signal handler.

10. What is CPU hotplug and how does it affect real-time processes?

CPU hotplug allows removing a CPU core from the scheduler at runtime (via echo 0 > /sys/devices/system/cpu/cpuN/online). When a core is offlined, the kernel migrates all processes away and sends SIGBUS to any process with hard affinity to that core. For real-time workloads, either disable hotplug at boot (maxcpus=), or subscribe to the CPU_DOWN_PREPARE notifier to gracefully migrate before the core goes offline.

11. What is cgroup CPU controller and how does it relate to CPU affinity?

The cgroup CPU controller can control a group's CPU weight and maximum bandwidth; affinity controls the eligible CPUs. They can be combined, but the resulting capacity depends on the parent cgroups, cpuset, quota period, and host load. Check the kernel and container runtime configuration before using either as a latency-control mechanism.

12. How does the scheduler handle affinity in a containerized environment?

In containerized environments, CPU affinity and cpusets interact in layered ways: 1) The container runtime (Docker, containerd) may set default cpuset cgroups limiting visible CPUs. 2) Inside the container, sched_setaffinity() is constrained by the cgroup cpuset subsystem. 3) Kubernetes CPU Manager and Topology Manager policies can affect CPU and NUMA placement for eligible pods; behavior depends on Kubernetes version and policy configuration. 4) On cgroup v2 systems, cpuset.cpus.effective determines the allowed mask visible to processes.

13. What is the difference between CPU isolation (isolcpus) and CPU affinity?

isolcpus is a kernel boot parameter that removes a CPU from the scheduler's default load balancing entirely — the kernel will never automatically place a process on that CPU. You must explicitly assign work using affinity. CPU isolation removes some CPUs from normal scheduler load balancing, but it does not automatically route interrupts or eliminate all kernel and hardware activity. Follow the kernel documentation for the specific isolation controls and validate the full setup under load.

14. What are the performance implications of context switching between CPUs with affinity?

Migration can change cache locality, but the cost depends on the working set and processor. Affinity does not eliminate interrupts, kernel work, or memory stalls. Use perf stat and application latency measurements to compare the target workload with and without affinity.

15. What is the difference between SCHED_FIFO and SCHED_RR at the assembly level?

At the kernel level, SCHED_FIFO processes run until they yield, block, or are preempted by a higher-priority process. The only difference from SCHED_RR is that SCHED_RR applies a time slice counter: when a FIFO task exhausts its quantum, it is moved to the end of its priority queue. In pseudocode: if (policy == SCHED_RR && counter == 0) enqueue(current, rq); pick_next(rq);. Choose the policy from the workload scheduling model and starvation risk; measure on the target system.

16. How does the kernel implement priority inheritance for futexes?

Linux supports priority-inheritance futex operations for synchronization where priority inversion matters. Their performance cost depends on the kernel and workload; benchmark the application if the uncontended lock path is performance-sensitive.

17. What is the difference between real-time latency and real-time throughput?

Latency is the time from an event to its response; throughput is the amount of work completed per unit time. A real-time requirement specifies deadlines and the consequence of missing them. Measure both on the target workload because lower latency may involve tradeoffs in throughput or resource use.

18. What is CONFIG_PREEMPT_NONE vs CONFIG_PREEMPT_VOLUNTARY vs CONFIG_PREEMPT?

These are kernel preemption configuration options: CONFIG_PREEMPT_NONE (server) — the kernel can only be preempted at explicit preemption points. CONFIG_PREEMPT_VOLUNTARY (desktop) — adds explicit preemption checks in additional kernel code paths. CONFIG_PREEMPT (preemptible kernel) — the kernel can be preempted anywhere except in interrupt context. CONFIG_PREEMPT_RT (real-time) — builds on CONFIG_PREEMPT with threaded IRQs, sleeping spinlocks, and mandatory preemption everywhere.

19. What are the trade-offs between threaded IRQs and interrupt handlers running in interrupt context?

On PREEMPT_RT, many interrupt handlers run in schedulable threads, while some interrupt work remains in hard-IRQ context. The exact behavior depends on the kernel, driver, and configuration. Measure interrupt and thread wake-up latency under expected interrupt load.

20. What is the worst-case latency achievable on a PREEMPT_RT kernel and what limits it?

There is no platform-independent worst-case figure. The result depends on kernel and hardware configuration, interrupts, drivers, virtualization, memory behavior, and the workload. Use `cyclictest` or `rtla timerlat` to measure a documented test run, then analyze the system for conditions the test may not cover.

Further Reading


Conclusion

CPU affinity and real-time scheduling are two levels of the same idea: taking control away from the default scheduler and making explicit placement and timing decisions. Affinity restricts eligible CPUs. Real-time policies change scheduling behavior and may reserve runtime. Neither proves that an application meets its deadlines.

For most applications, the default scheduler is perfectly adequate. When placement or deadline behavior matters, measure the complete workload on the target system and keep the assumptions visible.

The next step from here is to explore Kernel Architecture to understand how the scheduler fits into the broader kernel design, or to dig deeper into Process Scheduling Algorithms if you want to understand the algorithmic foundations of CFS.


Category

Related Posts

Real-Time Operating Systems

Understand RTOS concepts, scheduling guarantees, latency bounds, and the PREEMPT_RT patch for achieving real-time Linux.

#operating-systems #real-time-operating-systems #rtos

Network Performance: Latency, Throughput, Jitter & Loss

Learn to measure link capacity, throughput, delay variation, packet loss, and response time with ping, iperf3, and curl.

#networking #performance #latency

Latency, Availability, and Error Budgets for APIs

Set API latency and availability objectives, calculate error budgets, and use service level indicators to guide practical reliability trade-offs.

#api-reliability #latency #availability