Context switch

Computer simulation, one of the main cross-computing methodologies.

Process of storing the state of a process or thread, so that it can be restored and resume execution at a later point.

- Context switch

128 related topics

Relevance

Thread (computing)

Smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system.

A process with two threads of execution, running on one processor
400x400px

Processes are typically preemptively multitasked, and process switching is relatively expensive, beyond basic cost of context switching, due to issues such as cache flushing (in particular, process switching changes virtual memory addressing, causing invalidation and thus flushing of an untagged translation lookaside buffer, notably on x86).

Preemption (computing)

Act of temporarily interrupting an executing task, with the intention of resuming it at a later time.

Computer simulation, one of the main cross-computing methodologies.

Such a change in the currently executing task of a processor is known as context switching.

Linux kernel

Free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel.

Linux kernel 3.0.0 booting
Linux kernel 3.0.0 booting
Linus Torvalds at the LinuxCon Europe 2014 in Düsseldorf
The Linux kernel supports various hardware architectures, providing a common platform for software, including proprietary software.
Map of the Linux kernel
Four interfaces are distinguished: two internal to the kernel, and two between the kernel and userspace.
At XDC2014, Alex Deucher from AMD announced the unified kernel-mode driver. The proprietary Linux graphic driver, libGL-fglrx-glx, will share the same DRM infrastructure with Mesa 3D. As there is no stable in-kernel ABI, AMD had to constantly adapt the former binary blob used by Catalyst.
The Linux Storage Stack Diagram
TiVo DVR, a consumer device running Linux
An example of Linux kernel panic
An iPod booting iPodLinux
Redevelopment costs of Linux kernel
Boot messages of a Linux kernel 2.6.25.17

He started with a task switcher in Intel 80386 assembly language and a terminal driver.

Interrupt

Interrupt is a request for the processor to interrupt currently executing code (when permitted), so that the event can be processed in a timely manner.

interrupt sources and processor handling

In some usages, the term trap refers specifically to a breakpoint intended to initiate a context switch to a monitor program or debugger.

Synchronization (computer science)

In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data.

Figure 1: Three processes accessing a shared resource (critical section) simultaneously.
Figure 2: A process accessing a shared resource if available, based on some synchronization technique.
Figure 3: Changes from both server and client(s) are synchronized.

If proper synchronization techniques are not applied, it may cause a race condition where the values of variables may be unpredictable and vary depending on the timings of context switches of the processes or threads.

Scheduling (computing)

Action of assigning resources to perform tasks.

A sample thread pool (green boxes) with a queue (FIFO) of waiting tasks (blue) and a queue of completed tasks (yellow)
A highly simplified structure of the Linux kernel, which includes process schedulers, I/O schedulers, and packet schedulers

Context switches, in which the dispatcher saves the state (also known as context) of the process or thread that was previously running; the dispatcher then loads the initial or previously saved state of the new process.

Protection ring

In computer science, hierarchical protection domains, often called protection rings, are mechanisms to protect data and functionality from faults (by improving fault tolerance) and malicious behavior (by providing computer security).

Privilege rings for the x86 available in protected mode

At least one embedded database management system, eXtremeDB Kernel Mode, has been developed specifically for kernel mode deployment, to provide a local database for kernel-based application functions, and to eliminate the context switches that would otherwise occur when kernel functions interact with a database system running in user mode.

Kernel (operating system)

Computer program at the core of a computer's operating system and generally has complete control over everything in the system.

A kernel connects the application software to the hardware of a computer
Diagram of a monolithic kernel
In the microkernel approach, the kernel itself only provides basic functionality that allows the execution of servers, separate programs that assume former kernel functions, such as device drivers, GUI servers, etc.
The hybrid kernel approach combines the speed and simpler design of a monolithic kernel with the modularity and execution safety of a microkernel
A diagram of the predecessor/successor family relationship for Unix-like systems

Important decisions have to be made when designing the device management system, as in some designs accesses may involve context switches, making the operation very CPU-intensive and easily causing a significant performance overhead.

Computer multitasking

Concurrent execution of multiple tasks over a certain period of time.

Modern desktop operating systems are capable of handling large numbers of different processes at the same time. This screenshot shows Linux Mint running simultaneously Xfce desktop environment, Firefox, a calculator program, the built-in calendar, Vim, GIMP, and VLC media player.
Multitasking of Microsoft Windows 1.01 released in 1985, here shown running the MS-DOS Executive and Calculator programs

This "context switch" may be initiated at fixed time intervals (pre-emptive multitasking), or the running program may be coded to signal to the supervisory software when it can be interrupted (cooperative multitasking).

Process (computing)

Instance of a computer program that is being executed by one or many threads.

400x400px
A list of processes as displayed by htop
A process table as displayed by KDE System Guard
The various process states, displayed in a state diagram, with arrows indicating possible transitions between states.

However, multitasking allows each processor to switch between tasks that are being executed without having to wait for each task to finish (preemption).