Fact-checked by Grok 2 weeks ago

Context switch

A context switch is a fundamental mechanism in operating systems that enables multitasking by saving the current state (or context) of an executing process or thread—such as its register values, program counter, and stack pointer—and restoring the state of another process or thread, thereby transferring control of the CPU to it. This process allows a single CPU to appear to run multiple programs concurrently through time-sharing, providing the illusion of a virtual CPU for each process. Context switches occur either voluntarily, such as when a yields the CPU via a or blocks on an I/O operation, or involuntarily, triggered by events like interrupts that enforce time slices to prevent any single from monopolizing the . In practice, the operating system handles the switch using low-level code, such as a dedicated routine that pushes registers onto the current 's stack, updates the stack pointer, and pops the registers of the new to resume execution precisely where it left off. For threads within the same , the context may be lighter, often limited to registers and stack, whereas full switches also involve updating page tables and memory mappings for address space isolation. The overhead of switching is a critical , typically ranging from microseconds to milliseconds depending on the , and includes costs for /restoring , and TLB flushes, and scheduler decisions; excessive switching can degrade throughput, so operating systems it with appropriate time , often around 4-10 milliseconds in kernels like . Despite this cost, context switching is essential for responsive systems, supporting features like preemptive scheduling, where the OS can interrupt running tasks to fairness and prioritize interactive workloads.

Fundamentals

Definition and Purpose

A context switch is the process by which an operating system saves the state of a currently executing process or thread and restores the state of another, enabling the CPU to transition from one execution context to another. This involves suspending the active process, preserving its CPU state in kernel memory, and loading the corresponding state for the next process to resume execution precisely where it left off. The fundamental purpose of context switching is to support multitasking by allowing multiple processes to share a single CPU through , creating the illusion of concurrent execution without direct interference between them. This ensures equitable distribution of processor time, prevents any single process from monopolizing the CPU, and enhances overall , particularly in environments with diverse workloads. Key components of the execution context include CPU registers, such as the program counter (PC) that tracks the next instruction to execute, the stack pointer that manages the process's call stack, and general-purpose registers holding temporary computational data. These elements are collectively stored in the process control block (PCB), a kernel data structure that encapsulates the full state of a process, including its registers, memory mappings, and scheduling information, to facilitate accurate state preservation and restoration during switches. Context switching originated in pioneering time-sharing systems like , developed in the 1960s under to enable multiple users to access a computer simultaneously via remote terminals. In , implemented on the GE-645 hardware and first operational in 1967, context switches were achieved efficiently by updating the descriptor register to alter the active process's , supporting among concurrent users.

Role in Multitasking Operating Systems

In multitasking operating systems, context switching is a core mechanism that facilitates preemptive scheduling by saving the state of the currently executing or and restoring the state of another from the ready . This integration allows the to manage process queues—such as run queues organized by levels (e.g., 0-139 in )—and allocate time slices, typically in milliseconds, to ensure fair CPU sharing among competing tasks. For instance, in preemptive multitasking, a triggers the to evaluate priorities and lower-priority processes in favor of higher ones, enabling dynamic resource allocation without voluntary yielding. The primary benefits of context switching in this context include enhanced system throughput by interleaving CPU-bound and I/O-bound processes, preventing any single task from monopolizing resources. It also sustains the illusion of dedicated virtual memory for multiple programs by switching address spaces, allowing each process to operate as if it has exclusive access to the system's memory and CPU. This is particularly effective for balancing workloads, where I/O-bound processes (e.g., those awaiting disk access) are quickly rescheduled to favor CPU-bound ones, optimizing overall efficiency in environments with diverse task types. Building on the foundational concepts of processes and threads—where processes represent independent execution units with private address spaces and threads share resources within a process—context switching differs fundamentally from cooperative multitasking. In cooperative models, switches occur only when a task voluntarily yields control, such as during I/O blocking, which risks system hangs if a process fails to cooperate. Preemptive approaches, by contrast, enforce involuntary switches via hardware timers, ensuring robustness. In modern operating systems like Linux and Windows, this capability is indispensable for managing thousands of concurrent tasks, including in virtualized environments where hypervisors layer additional scheduling over guest OS kernels to support isolated virtual machines.

Triggers and Cases

Interrupt-Driven Switches

Interrupt-driven context switches occur when hardware or software interrupts preempt the execution of the current process, allowing the operating system to respond to asynchronous events while maintaining system responsiveness in multitasking environments. These switches are essential for handling time-sensitive operations, such as responding to external device signals or internal requests, thereby enabling the illusion of concurrency by interleaving process execution. Hardware interrupts, which are asynchronous events generated by external devices, include interrupts for periodic scheduling and I/O completion interrupts signaling the end of data transfers or device readiness. For instance, a interrupt might occur at fixed intervals (e.g., every ) to enforce among processes, while an I/O interrupt from a network card notifies the CPU of incoming packets. Software interrupts, in contrast, are synchronous and typically initiated by the current , such as through system calls that request kernel services like or . Both types preempt the running , transitioning control to the without the process explicitly yielding. Upon an interrupt, the hardware automatically saves a minimal set of processor state—such as the , flags, and stack pointer—before vectoring to an service routine (ISR) via a predefined . The ISR, a kernel-level handler, performs device-specific actions (e.g., acknowledging the interrupt or queuing data) and then invokes the scheduler if the interrupt indicates a higher-priority process is ready or if the current process's time slice has expired. The scheduler then decides whether to perform a full context switch, restoring the state of another process; otherwise, it returns control to the interrupted process. This minimal initial state save in the ISR distinguishes interrupt-driven switches from other mechanisms, as it prioritizes low-latency response over complete context preservation at the outset. In real-time systems, such as those using device drivers for embedded controllers, these switches ensure timely handling of critical events like sensor inputs, preventing delays that could compromise system integrity. A component in architectures like x86 is the (), a kernel-maintained array of up to 256 entries that maps interrupt vectors to ISR addresses, segment selectors, and privilege levels. When an interrupt occurs, the uses the IDTR register to locate the IDT and dispatches to the corresponding handler, which operates in kernel mode and may trigger a context switch if scheduling is required. Task gates in the IDT can directly initiate a task switch by loading a new Task State Segment (TSS), though interrupt and trap gates more commonly lead to switches via software decisions in the handler or scheduler. This hardware-supported routing ensures efficient, vectored handling, supporting the responsive design of modern operating systems.

Scheduler-Induced Switches

Scheduler-induced context switches occur when the operating system's scheduler decides to allocate the CPU to a different process or thread to ensure fair resource sharing and prevent any single process from monopolizing the processor. These switches are proactive mechanisms driven by scheduling policies rather than external events, contrasting with reactive switches triggered by interrupts. In preemptive multitasking systems, the scheduler can forcibly interrupt a running process to initiate a switch, typically upon expiration of a time slice or when a higher-priority process becomes ready. This approach is essential for maintaining responsiveness in multi-user environments, as it guarantees bounded execution time for each process. Common scheduling algorithms that lead to such switches include First-Come, First-Served (FCFS), Shortest Job First (SJF), and priority-based methods. FCFS operates non-preemptively in its basic form, where switches happen only when the current process completes or blocks, but preemptive variants like First (SRTF) for SJF trigger switches when a shorter job arrives. scheduling assigns levels to processes, preempting lower-priority ones upon higher-priority arrivals to optimize for urgency or importance. In , a hallmark of preemptive systems, each process receives a fixed time quantum, typically 10-100 milliseconds in Unix-like systems, after which the scheduler switches to the next process if the current one has not finished. These algorithms collectively ensure no process indefinitely holds the CPU, promoting fairness and efficiency. In cooperative or non-preemptive scenarios, scheduler-induced switches rely on voluntary yields, where processes explicitly relinquish the CPU through system calls, allowing the scheduler to select the next runnable task without forced interruption. This contrasts with fully preemptive systems but still achieves multitasking through policy-driven decisions. A prominent example is the Linux kernel's Earliest Eligible Virtual Deadline First (EEVDF) scheduler, which replaced the Completely Fair Scheduler (CFS) in version 6.6 (2023) and uses a red-black tree to maintain processes sorted by virtual runtime, selecting the one with the earliest virtual deadline (based on the lowest vruntime) for execution to approximate ideal fairness while improving latency for interactive tasks. EEVDF dynamically adjusts time slices based on process count and load, ensuring proportional CPU allocation while minimizing switches through efficient tree operations. More recently, as of Linux kernel 6.12 (November 2024), the sched_ext framework enables extensible scheduling policies implemented in user space using eBPF, allowing custom scheduler classes alongside EEVDF. Timer interrupts often serve as the mechanism to invoke the scheduler for these preemptive decisions in modern systems.

Mode Transitions

Mode transitions in operating systems involve switching the processor's execution mode from user mode, which imposes restrictions on to sensitive and regions to protect , to kernel mode, where unrestricted privileges enable direct interaction with and core OS functions. This transition is triggered by such as calls (e.g., requests for I/O or ), traps (software-generated exceptions like ), or exceptions (e.g., page faults), allowing user-level code to invoke privileged operations without compromising security. Upon initiation, the processor automatically handles the mode change, ensuring isolation between the two environments. The process of a mode transition entails a partial context save rather than a complete process state exchange. When entering kernel mode, the processor pushes essential user-mode state—such as general-purpose registers, the (indicating the instruction that caused the transition), and processor status flags—onto a per-process kernel stack, often using a structure like the pt_regs in Linux to capture this snapshot. This avoids swapping the full process control block (PCB), which includes thread-local storage and scheduling information, as the same process remains active; instead, execution shifts to kernel code on a dedicated kernel stack segment for isolation. Returning to user mode involves popping this saved state and resuming from the original point, typically via a return instruction like IRET on x86 or ERET on ARM, restoring the prior privilege level and registers. These transitions are uniquely positioned to uphold security boundaries, as user-mode code cannot arbitrarily access kernel resources, thereby preventing unauthorized manipulations that could lead to system crashes or exploits. No full inter-process context switch is mandated during the mode change itself; however, if the kernel handler encounters a scheduling event (e.g., a higher-priority process becoming runnable), the scheduler may then initiate a complete PCB swap post-handler. This design minimizes overhead while enforcing privilege separation essential for modern multitasking environments. Architectural implementations vary to support these transitions efficiently. On x86 processors, the switch occurs between Ring 3 (least privileged, ) and Ring 0 (most privileged, kernel ), facilitated by dedicated instructions like SYSCALL (which saves the RIP and RFLAGS to the kernel's model-specific registers before changing the ) or for exceptions, ensuring atomic privilege elevation. In contrast, ARM architectures employ Exception Levels (ELs), transitioning from EL0 (unprivileged, equivalent to ) to EL1 (privileged, kernel ) via exceptions such as the SVC instruction for system calls; state is preserved in banked registers (e.g., SPSR_EL1 for ) or the , with the exception register (ELR_EL1) to the resumption . These hardware features optimize the partial save/restore , distinguishing transitions from costlier full switches.

Mechanism

Core Steps

A context switch involves a structured sequence of operations to transfer control from one or to another, ensuring the operating system's ability to multiplex the CPU among multiple execution contexts. The high-level begins with saving the state of the currently executing , which includes critical elements such as the (PC), registers, and status flags, into its (PCB) or equivalent structure. Next, the scheduler updates relevant data structures, such as ready queues or priority lists, to reflect the transition. The system then selects and loads the state of the next from its PCB, finally resuming execution by to the restored PC. These operations occur exclusively in kernel mode, where the operating system has privileged to hardware resources, often entered via an or that triggers the switch. During this phase, if the incoming and outgoing entities have distinct spaces, the must flush the (TLB) to invalidate cached virtual-to-physical mappings and prevent violations. This step ensures but adds to the switch's , as the TLB flush typically involves setting all entries' valid bits to invalid. To maintain atomicity and prevent interruptions during the vulnerable saving and loading phases, the kernel briefly disables interrupts, ensuring no concurrent events can alter the CPU state mid-switch; interrupts are re-enabled once the core operations complete. This mechanism handles by preserving per-thread data in the while avoiding interference with shared resources. In POSIX-compliant systems, context switches between threads within the same omit the full address space reload and TLB flush, as threads share the process's , thereby streamlining the to primarily involve and adjustments.

State Management

During a context switch, the operating system saves the execution state of the current process or thread into a dedicated data structure known as the , also called a task control block in some systems, which resides in memory. The PCB encapsulates all essential information required to resume the process later, including the process identifier, current state (such as ready, running, or waiting), program counter pointing to the next instruction, CPU registers (encompassing general-purpose registers, floating-point registers, stack pointers, and index registers), scheduling details like priority and queue pointers, memory-management information such as page tables and virtual memory mappings, accounting data on resource usage, and I/O status including lists of open files and signal handlers. These components ensure that the process's computational context—ranging from architectural state like registers to higher-level resources like file descriptors—remains intact across suspensions and resumptions. The saving technique involves copying the active CPU state, including registers and the , from into the allocated in -protected memory, while details like base registers are updated to reflect the current . Restoration reverses this process: the loads the target process's PCB contents back into the CPU registers to reinstate architectural state, and updates the (MMU) with the appropriate tables to switch the , enabling seamless continuation of execution. This -mediated transfer minimizes direct access overhead and enforces isolation between processes. In multi-core systems, incorporates per-CPU variables—such as scheduler runqueues and counters stored in CPU-local data structures—to reduce lock contention and scalability issues during concurrent switches across cores. Additionally, lazy restoration techniques defer full and TLB () invalidations until necessary, avoiding immediate flushes of caches during switches and instead handling inconsistencies , which mitigates penalties in register-heavy architectures like . For example, in the Windows NT kernel, the EPROCESS serves as the primary PCB equivalent, holding context including registers and info, with a typical size of 1-2 per to balance detail and efficiency.

Overhead and Optimization

Performance Costs

Context switches incur both direct and indirect performance costs, with the direct costs arising primarily from saving and restoring processor , while indirect costs from disruptions to the CPU's microarchitectural . On modern CPUs, the direct overhead for saving and restoring registers and other typically ranges from 1 to 10 microseconds, depending on the and workload; for instance, measurements on systems with processors show around 2.2 microseconds for unpinned threads without floating-point involvement. This involves handling a significant number of registers, such as the 16 general-purpose registers in architectures, which must be preserved in kernel or control blocks. Indirect costs often dominate, particularly from cache and TLB perturbations, where switching processes flushes or invalidates cached and address mappings, leading to misses that can be up to 100 times slower than hits due to the of fetching from lower levels of the . These misses can extend the effective overhead to tens or hundreds of microseconds per switch, with cache perturbation alone accounting for 10-32% of total L2 misses in some workloads. The total cost of a context switch can thus be modeled as \text{Cost} = \text{Save\_time} + \text{Load\_time} + \text{Cache\_miss\_penalty}, where the miss penalty incorporates the amplified from disrupted locality. Factors influencing these costs include the of switches and the of ; for example, rates exceeding switches per second can degrade throughput by 5-15% or more, as the overhead scales linearly with and compounds indirect effects like increased thrashing. In , this often signals performance bottlenecks in high-load scenarios. Tools such as Linux's /proc/stat (monitoring the ctxt field for total switches) and perf stat -e context-switches enable precise measurement of switch rates and associated overheads. In 2020s cloud environments with and dense container deployments, context switches contribute significantly to overall CPU overhead, particularly in colocated workloads where scheduling demands can consume a substantial portion of at peak loads. This underscores the need for careful workload design to mitigate cumulative impacts in scalable systems.

Hardware Support vs. Software Approaches

support for context switching leverages specialized instructions and architectural features to accelerate the saving and restoration of process or states, minimizing overhead compared to traditional software methods. In x86 architectures, Intel's XSAVE and XRSTOR instructions, introduced in 2008, enable efficient management of extended states, such as those introduced by SIMD extensions, by allowing selective saving and restoration of only modified components during switches. These instructions optimize context switching by avoiding unnecessary operations on unmodified states, particularly beneficial when tasks do not utilize all available registers like or higher AVX bits. Additionally, shadow registers—duplicate sets of general-purpose registers maintained by the CPU—facilitate rapid switching by allowing the to swap entire register file sets in , as implemented in Intel's Nios II and Nios V to accelerate interrupt handling without software intervention. As of 2025, Intel's Advanced Performance Extensions (APX) further enhance context switching with additional registers and optimized state management. In other architectures, similar hardware accelerations address specific needs. RISC-V extensions like fastirq, implemented in cores such as CV32RT, use banked register files and background saving mechanisms to achieve interrupt latencies as low as six clock cycles and context switches under 110 clock cycles, enhancing real-time performance in embedded systems. For ARM-based systems, Virtualization Host Extensions (VHE), introduced in ARMv8.1, optimize context switching in virtualized environments by allowing the host OS to run at the same exception level as the hypervisor, reducing the need for additional traps and state transitions during VM exits and entries. These features are particularly valuable in hypervisors like KVM/ARM, where VHE significantly improves overall virtualization performance by streamlining host-guest interactions. Pure software approaches to context switching rely on kernel-level , typically written in , to manually save and restore CPU registers, stack pointers, and other components to and from process control blocks or kernel stacks. Optimizations in software methods include selective preservation—saving only essential registers for the current —and techniques to avoid unnecessary cache or TLB flushes, such as using address space identifiers (ASIDs) to maintain translations across switches. Recent patches further refine these by streamlining register handling and reducing redundant operations during switches. Comparisons between -assisted and methods highlight substantial gains from , with hardware features reducing latencies compared to software-only approaches that rely on sequential operations. In virtualized scenarios, hardware support such as ARM's VHE cuts VM context switch overhead by eliminating extra exception level transitions, enabling near-native performance for hypervisor workloads. Overall, approaches excel in low-latency environments like systems and , while software methods offer greater portability across processor generations.

Practical Examples

Non-Switching Scenarios

In operating systems, certain execution patterns inherently avoid context switches by keeping the CPU within the same or context, thereby eliminating the need to save and restore states across different execution units. procedure calls within a single exemplify this, as they involve only stack frame adjustments and register manipulations without altering the 's or invoking the scheduler. Similarly, busy-waiting loops, where a repeatedly checks a condition in a tight spin without yielding control, prevent context switches by maintaining uninterrupted execution on the same core, often used in low-latency scenarios to bypass blocking operations that would trigger scheduler intervention. Single-threaded execution without preemption further ensures no switches occur, as there are no concurrent competing for the CPU, allowing the program to run to completion or voluntary yield points without external interruption. These non-switching scenarios offer significant benefits, including zero overhead from state preservation and restoration, which typically consumes hundreds of CPU cycles per switch. By avoiding switches, they preserve locality, as the remains resident in the processor's caches without due to context changes, and prevent Translation Lookaside Buffer (TLB) flushes that would otherwise invalidate virtual-to-physical address mappings and incur miss penalties. In embedded systems, non-preemptive kernels are particularly valued for minimizing context switches to achieve deterministic behavior, where task execution times are predictable without the variability introduced by involuntary preemptions. These kernels rely on scheduling, allowing tasks to run until they complete or explicitly yield, which suits resource-constrained environments requiring bounded response times, such as control applications. User-level threading libraries, such as GNU Pth, enable concurrency without kernel-mediated context switches by managing thread scheduling entirely in , where switches involve lightweight stack pointer adjustments rather than full traps. This approach avoids the overhead of mode transitions to , allowing applications to multiplex multiple threads onto fewer threads efficiently.

Interrupt-Caused Switches

Interrupt-caused context switches occur when a hardware or software interrupt disrupts the execution of the current process or thread, prompting the operating system to save the current execution state and potentially load the state of another process or the interrupt handler itself. This type of switch is asynchronous, meaning it happens unpredictably from the perspective of the running program, in contrast to synchronous switches triggered by explicit system calls or voluntary yields. The interrupt signal—generated by devices like timers, disks, or network interfaces—triggers the CPU to vector to an interrupt service routine (ISR), where the kernel may invoke the scheduler to decide if a full context switch is necessary. A primary example is the timer interrupt, which enforces preemptive multitasking in systems. The hardware timer, programmed by the to expire after a fixed quantum (typically 10-100 milliseconds), generates an interrupt that preempts the current , saving its registers, , and other state into the process control block (PCB). The scheduler then selects the next ready , restoring its state to resume execution. This mechanism ensures fair CPU allocation among multiple processes, as described in , where the timer interrupt acts as the primary trigger for switches. Without such interrupts, non-preemptive systems would allow a single process to monopolize the CPU indefinitely. Another common case involves I/O-related interrupts, such as those signaling the of disk reads or arrivals. When a issues an I/O request, it blocks and is moved to a wait queue, but the interrupt upon notifies the , which updates the to ready and may trigger a context switch to resume it or prioritize another task. For instance, in paging systems, a interrupt (an exception treated as an ) leads to disk I/O, followed by a that prompts the scheduler to switch contexts. These switches are critical for efficient resource utilization but introduce overhead from save/restore operations, often mitigated by features like controllers and fast handlers. In terms of implementation, the low-level —executed in mode—handles the initial state preservation using CPU-specific instructions (e.g., for registers on x86), while higher-level code manages PCB updates and scheduler calls. Modern systems, such as those using multi-level interrupt priorities, minimize by deferring non-critical processing to bottom halves or softirqs, reducing the frequency of full switches. Quantitative impacts include typical overheads of 1-10 microseconds per switch on contemporary hardware, though this varies with system load and frequency. In recent developments as of , has focused on mitigating context switch overhead in densely packed workloads, such as serverless applications on clusters. Techniques like workload-aware scheduling and reducing unnecessary switches can significantly improve performance in high-density environments where frequent interrupts amplify overhead.

References

  1. [1]
    [PDF] Mechanism: Limited Direct Execution - cs.wisc.edu
    If the decision is made to switch, the OS then executes a low-level piece of code which we refer to as a context switch. A context switch is conceptually simple ...
  2. [2]
    Context switching - PDOS-MIT
    The program's view of context switching · When a process makes a system call that blocks, the kernel arranges to take the CPU away and run a different process.
  3. [3]
    [PDF] CS111, Lecture 18 - Dispatching and Scheduling
    A context switch means changing the thread currently running to another thread. We must save the current thread state and load in the new thread state. 1. Push ...
  4. [4]
    Lecture 3: processes, isolation, context switching
    For each process, the OS maintains a process control block (PCB) (a data structure that lives in kernel space), containing the saved state of the registers ...<|separator|>
  5. [5]
    [PDF] Virtual Memory, Processes, and Sharing in MULTICS
    Context switch only requires changing DBR for the new process. 7. Base Registers: Complete address a. AP: argument pointer b. BP: base pointer c. LP: linkage ...
  6. [6]
    [PDF] 15 410
    Preemptive multitasking. □. All four cases cause context switch. Preemptive ... Static: fixed property (engineered?) □. Dynamic: function of task behaviour.
  7. [7]
    Operating Systems: CPU Scheduling
    ### Summary on Context Switching in Multitasking OS, Kernel Integration, Benefits, Prerequisites, and Modern Relevance
  8. [8]
    [PDF] Processes & Threads - GMU CS Department
    How are these illusions maintained? ➢ Process executions interleaved (multitasking). ➢ Address spaces managed by virtual memory system ... ❑ Context switching ...
  9. [9]
    [PDF] Operating-Systems-Interrupts.pdf - oer at GitLab
    Whenever an interrupt occurs, a so-called context switch takes place. So that means the. CPU gets interrupted in whatever it is currently doing. To resume ...
  10. [10]
    [PDF] Interrupts and System Calls
    Interrupt overview. • Each interrupt or exception includes a number indicating its type. • E.g., 14 is a page fault, 3 is a debug breakpoint.
  11. [11]
    [PDF] Chapter 3 System calls, exceptions, and interrupts - Columbia CS
    Interrupts are generated by hardware de- vices that need attention of the operating system. For example, a clock chip may gen- erate an interrupt every 100 msec ...
  12. [12]
    [PDF] The Context-Switch Overhead Inflicted by Hardware Interrupts (and ...
    The interrupt invokes a kernel routine, called the tick handler that is responsible for various important OS activities including (1) delivering timing services ...
  13. [13]
    [PDF] Intel® 64 and IA-32 Architectures Software Developer's Manual
    This is Volume 3A, Part 1 of the Intel 64 and IA-32 manual, which is a system programming guide. The manual has nine volumes.
  14. [14]
    [PDF] Scheduling: Introduction - cs.wisc.edu
    Virtually all modern sched- ulers are preemptive, and quite willing to stop one process from run- ning in order to run another. This implies that the scheduler ...
  15. [15]
    Operating Systems Lecture Notes Lecture 6 CPU Scheduling
    Preemptive scheduler reruns scheduling decision when process becomes ready. If the new process has priority over running process, the CPU preempts the running ...
  16. [16]
    Operating Systems: CPU Scheduling
    Most modern systems use time quantum between 10 and 100 milliseconds, and ... Real-time systems require pre-emptive priority-based scheduling systems.
  17. [17]
    6. Scheduling - Computer Science from the Bottom Up
    Co-operative scheduling is where the currently running process voluntarily gives up executing to allow another process to run. · Preemptive scheduling is where ...
  18. [18]
    CFS Scheduler - The Linux Kernel documentation
    CFS stands for “Completely Fair Scheduler,” and is the “desktop” process scheduler implemented by Ingo Molnar and merged in Linux 2.6.23.Missing: paper | Show results with:paper
  19. [19]
    15 Tuning the task scheduler - SUSE Documentation
    A red-black tree is a type of self-balancing data search tree which provides inserting and removing entries in a reasonable way so that it remains well balanced ...15.2 Process Classification · 15.3 Completely Fair... · 15.3. 7 Debugging Interface...<|control11|><|separator|>
  20. [20]
    [PDF] Cooperative & Preemptive Context Switching
    Nov 27, 2016 · Cooperative tasking is non-preemptive, where tasks run to completion. Preemptive tasking allows tasks to be preempted by others. Most systems ...
  21. [21]
    Intel® 64 and IA-32 Architectures Software Developer Manuals
    Oct 29, 2025 · These manuals describe the architecture and programming environment of the Intel® 64 and IA-32 architectures.
  22. [22]
    Privilege and Exception levels - Arm Developer
    This guide introduces the exception and privilege model in Armv8-A and Armv9-A.Missing: Manual switch
  23. [23]
    Entry/exit handling for exceptions, interrupts, syscalls and KVM
    Transitions between execution domains require state updates, which are strictly ordered. The order depends on the transition type, such as syscalls, KVM, ...
  24. [24]
    Exception levels - Learn the architecture - AArch64 Exception Model
    The name for privilege in AArch64 is Exception level, often abbreviated to EL. The Exception levels are numbered, normally abbreviated and referred to as EL<x>.Missing: Manual switch
  25. [25]
    [PDF] Abraham-Silberschatz-Operating-System-Concepts-10th-2018.pdf
    Our aim is to present these concepts and algorithms in a general setting that is not tied to one particular operating system. However, we present a large number ...
  26. [26]
    [PDF] Processes & Threads - Computer Science (CS)
    Steps in context switch: high-level. • Save the current process's execution state to its PCB. • Update current's PCB as needed. • Choose next process N.
  27. [27]
    [PDF] Paging: Faster Translations (TLBs) - cs.wisc.edu
    The TLB valid bit is quite useful when performing a context switch too, as we'll discuss further below. By setting all TLB entries to invalid, the system can ...
  28. [28]
    [PDF] Lecture 6: September 20 6.1 Threads - LASS
    A context switch between kernel threads belonging to the same process requires only the registers, program counter, and stack to be changed; the overall memory ...
  29. [29]
  30. [30]
    [PDF] Lazy Context Switching Algorithms for Sparc-like Processors - ITEC
    The necessary context switching basically consists of changing the address space and sav- ing/restoring the processor's registers. ... For better performance we ...
  31. [31]
    EPROCESS - Geoff Chappell, Software Analyst
    Jun 15, 2016 · The EPROCESS structure (formally _EPROCESS) is the kernel's representation of a process object. For instance, if the ObReferenceObjectByHandle function ...Missing: context switch
  32. [32]
    Measuring context switching and memory overheads for Linux threads
    Sep 4, 2018 · Without pinning, the switch time goes up to ~2.2 microseconds [2]. These numbers are largely consistent with the reports in the fibers talk ...
  33. [33]
    [PDF] A Case Against (Most) Context Switches - acm sigops
    May 31, 2021 · Context switches cause high overheads, disrupt execution, require expensive state saving, and lead to poor caching behavior, impacting ...Missing: driven | Show results with:driven
  34. [34]
    x64 Architecture Overview and Registers - Windows drivers
    x64 extends x86's eight general-purpose registers to be 64-bit and adds eight new 64-bit registers. The 64-bit registers have names that begin with "r". For ...
  35. [35]
    [PDF] Quantifying The Cost of Context Switch∗ - USENIX
    Context switch costs include direct costs from saving/restoring registers and indirect costs from cache sharing, which can be measured by c2-c1.
  36. [36]
    Introducing Intel® Advanced Performance Extensions (Intel® APX)
    Oct 31, 2024 · The new GPRs are XSAVE-enabled, which means that they can be automatically saved and restored by XSAVE/XRSTOR sequences during context switches.
  37. [37]
    Intel Details APX - Advanced Performance Extensions - Phoronix
    Jul 24, 2023 · The new GPRs are XSAVE-enabled, which means that they can be automatically saved and restored by XSAVE/XRSTOR sequences during context switches.Missing: efficiency | Show results with:efficiency
  38. [38]
    6.3. Shadow Register - Intel
    May 22, 2025 · Both the Nios® II and Nios® V processors support shadow registers, which were developed solely to improve context switching upon an interrupt.
  39. [39]
    CV32RT: Enabling Fast Interrupt and Context Switching for RISC-V ...
    In this work, we present fastirq, a fast interrupt extension for RISC-V embedded systems. We implement the extension on CV32RT, a 32-bit, in-order, single ...
  40. [40]
    Virtualization host extensions - Arm Developer
    This arrangement can be inefficient, because it may involve additional context switching. The kernel will need to handle some differences between running at EL1 ...
  41. [41]
    [PDF] Optimizing the Design and Implementation of the Linux ARM ...
    Jul 14, 2017 · To run existing hypervisor OS kernels in EL2 with almost no modifications, ARM introduced the Virtualization Host. Extensions (VHE) in ARMv8.1.<|separator|>
  42. [42]
    Context Switching & Performance: What Every Developer Should ...
    Dec 12, 2024 · Understand how context switching affects CPU registers, caches, TLB, and pipeline performance, and learn strategies to mitigate performance penalties.Missing: variables lazy
  43. [43]
  44. [44]
    New Patches Aim To Optimize Context Switching With ... - Phoronix
    Nov 9, 2024 · A set of Friday night patches provide for some exciting context switching optimizations to the Linux kernel.
  45. [45]
    How does context switch time depend on hardware architecture?
    Feb 9, 2016 · A context switch could take anywhere from a few 100 nanoseconds to few microseconds depending upon the CPU architecture and the size of the ...
  46. [46]
    [PDF] ARM Virtualization: Performance and Architectural Implications
    When KVM ARM sends a network packet, it traps to the hypervisor, context switching the EL1 state, and then the host OS instance directly sends the data on the ...
  47. [47]
    [PDF] EE382V: Embedded System Design and Modeling Lecture 4: Outline
    • Deterministic vs. non-deterministic behavior. • Preemptive vs. non-preemptive concurrency. • Atomic operations. Source: R. Doemer, UC Irvine. Page 3. EE382V ...
  48. [48]
    [PDF] SHIM: A Deterministic Model for Heterogeneous Embedded Systems
    Many systems can be executed with an unfair, non-preemptive scheduler (i.e., one that only regains control from a process when the process reaches a read or ...
  49. [49]
    Introduction to Real-time Systems - ROS2 Design
    However, a real-time system is not defined by low latency, but by a deterministic schedule: it must be guaranteed that the system finishes a certain task by a ...
  50. [50]
    [PDF] Application-specific User-Level Thread Schedulers
    This means that all context switches are performed in user space (either preemptively or cooperatively) by a separate library-specific scheduler without kernel ...
  51. [51]
    Operating Systems: I/O Systems
    Interrupts allow devices to notify the CPU when they have data to transfer or when an operation is complete, allowing the CPU to perform other duties when no I/ ...<|control11|><|separator|>
  52. [52]
    [PDF] Chapter 2 Processes and Threads
    Skeleton of what the lowest level of the operating system does when an interrupt occurs. Implementation of Processes (3). Tanenbaum, Modern Operating Systems 3 ...