Table of Contents
When to exchange?" >When to exchange?
Interrupt processing" >Interrupt processing
Exchange of user mode or kernel mode" >Exchange of user mode or kernel mode
Context exchange:Specific steps" >Context exchange:Specific steps
Context exchange: implemented by software or hardware" >Context exchange: implemented by software or hardware

Context exchange: specific steps

Jun 20, 2017 pm 01:25 PM
context exchange

Context switch (context switch), also known as environment switch, computer terminology, is a state (context) that stores and reconstructs the CPU, so it allows multiple Processes can share the computing process of a single CPU resource. When you want to swap processes on the CPU, you must first store the status of the current process, and then read the status of the process to be executed back to the CPU.

When to exchange?

There are three possible situations where context exchange will occur, namely:

Multi-tasking

The most common one is that in some scheduling algorithms, a trip sometimes needs to temporarily leave the CPU to allow another trip to come in and run on the CPU. In a preemptive multiplexing system, each trip will be executed in turn for a variable length of time. These time periods are called time slices. If the process does not voluntarily give up the CPU (for example, when performing I/O operations, the process needs to give up the right to use the CPU), when the time limit expires, the system will generate a timed interrupt, and the operating system will schedule other processes to be executed. This mechanism is used to ensure that the CPU is not monopolized by processes that rely more on processor operations. If there is no scheduled interrupt, the process will continue to execute unless it voluntarily gives up the CPU. For trips with a lot of I/O instructions, they often cannot be executed for long before they need to give up the CPU; while trips that rely more on the processor have relatively fewer I/O operations, but can continue to use the CPU, forming a monopoly. Phenomenon. This is the Convoy effect.

Interrupt processing

When receiving an interrupt (Interrupt), the CPU must perform context switching.

Exchange of user mode or kernel mode

When the exchange of user mode and kernel mode occurs, there is no need for context exchange; and the difference between user mode and kernel mode The exchange itself is not a context exchange. However, depending on the operating system, sometimes a context exchange step is performed at this time.

Context exchange:Specific steps

In an exchange, the status of the first trip should be recorded somewhere, so that when When the scheduler returns to this schedule, it can rebuild the schedule and continue the operation.

The so-called "trip status" here includes all registers used by this trip, especially the program counter; plus all specific data that the operating system may require. These data are generally stored in a data structure called a process control block (PCB).

Context exchange: implemented by software or hardware

Context exchange can be divided into mainly implemented by software or implemented by hardware. Some CPUs, such as Intel 80386 or higher-end processors of the same series, have hardware designs that support context switching.


The above is the detailed content of Context exchange: specific steps. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Add custom context menu items to the File Explorer menu in Windows 11 Add custom context menu items to the File Explorer menu in Windows 11 Apr 25, 2023 pm 06:19 PM

Microsoft has changed the context menu in File Explorer when launching the Windows 11 operating system. File Explorer has two context menus in Windows 11: When the user right-clicks a file or folder in File Manager, the new compact menu opens first. The classic context menu can be opened from this new menu or using a shortcut. There is also an option to restore the classic context menu in Windows 11’s File Explorer so that it opens by default. Programs can add their entries to the new context menu, but they need to have the correct programming to do so. Windows 11 users can use Windows app custom context menus to add their

How to add swap space on Ubuntu 22.04 LTS How to add swap space on Ubuntu 22.04 LTS Feb 20, 2024 am 11:12 AM

Swap space plays an important role in Linux systems, especially when the system is low on memory. It acts as a backup memory storage space that helps the system run smoothly and maintain stability even under high load. This article provides you with a detailed guide to adding swap space on Ubuntu 22.04LTS to ensure that your system performance is optimized and can handle various workloads. Understanding Swap Space Swap space provides virtual memory that is used to supplement the system's physical RAM. When the system is low on RAM, the kernel swaps data to disk to prevent out-of-memory and system crashes. Linux systems commonly use swap space to handle this situation. Run multiple memory-intensive applications simultaneously to process very large files or data

Python program: Swap the positions of the first and last elements in a matrix between columns Python program: Swap the positions of the first and last elements in a matrix between columns Sep 08, 2023 pm 04:29 PM

A matrix is ​​a two-dimensional array of numbers arranged in rows and columns. Python does not have any data type to represent matrices, but we can use nested lists or NumPy arrays as matrices. See the following input and output scenarios to see how to swap the first and last column elements of a matrix. Input-Output Scenario Suppose we have a 3X3 matrix represented using a list of lists. The output matrix will be the resulting matrix of swapping the first and last column elements. Inputmatrix:[1,3,4][4,5,6][7,8,3]Outputmatrix:[4,3,1][4,5,6][3,8,7]Let us consider another A matrix whose rows and columns are unequal. Inputmatrix:

Microsoft promises to make Windows 11 right-click menu faster Microsoft promises to make Windows 11 right-click menu faster May 01, 2023 am 11:13 AM

Windows 11 continues to be updated regularly, and reports suggest that SunValley 2 will address most of the major issues with the new operating system. Windows 11 brings several design overhauls, including a new Start menu, Notification Center, taskbar, and modern context menus. Context menus are a core part of the operating system's interface (especially File Explorer) and have been updated to a new design, which seems to be causing slow performance. There is an issue with Windows 11's context menu when you right-click on a file or folder in File Explorer. As part of its efforts to modernize its operating system, Microsoft has reduced the number of options in context menus and started using icons/buttons for options like copy or cute. Although this

Windows 11: How to Remove Editing with Clipchamp from File Explorer's Context Menu Windows 11: How to Remove Editing with Clipchamp from File Explorer's Context Menu May 03, 2023 pm 05:07 PM

Clipchamp is the new default application for Microsoft's Windows 11 operating system. Microsoft purchased the web-based video editor in 2021 and integrated it into development builds of Windows 11 in early 2022. The free version of Clipchamp wasn't really usable at the time because it had too many limitations. It watermarks all videos and limits exports to 480p. Microsoft has lifted some restrictions and changed available plans. Export now supports 1080p, and the free version no longer adds a watermark to the export. Microsoft makes Clipchamp a default app in Windows 11 2022 update. Windows1

This little app adds an acrylic effect to old Windows 10 and 11 context menus This little app adds an acrylic effect to old Windows 10 and 11 context menus May 16, 2023 pm 06:37 PM

While Microsoft is working day and night to make Windows 11 more modern and polished, the operating system retains remnants of an older era beneath its skin. For example, there are two context menus: one modern and one traditional. If you're unhappy with the look of your old menus in Windows 11 (and Windows 10), here's a small open source app (via OnMsft) that thanks them for using Acrylic effects to make them prettier. TranslucentFlyouts is a small application that replaces boring-looking solid backgrounds with translucent effects. You can personalize styles (Acrylic, Aero, Transpare

Checks whether a string can form a palindrome string by swapping character pairs at indices with unequal characters in a binary string Checks whether a string can form a palindrome string by swapping character pairs at indices with unequal characters in a binary string Sep 02, 2023 pm 08:09 PM

Problem Statement We have a string str and a binary string B. The length of both strings is equal to N. We need to check if we can make string str a palindrome string by swapping its characters multiple times on any pair of indexes containing unequal characters in string B. Example Example Input str=‘AAS’ B=‘101’ Output ‘YES’ The Chinese translation of Explanation is: Explanation We can exchange str[1] and str[2] because B[1] and B[2] are not equal. The final string can be 'ASA'. Input str=‘AASS’ B=‘1111’ and output ‘No’. The Chinese translation of Explanation is: Explanation that we cannot make the string palindrome,

Windows 11 version 22H2: File Explorer changes Windows 11 version 22H2: File Explorer changes May 01, 2023 pm 08:04 PM

In the fourth part of this series, we’ll take a look at the default file manager tool, File Explorer, and the changes Microsoft plans to introduce in the Windows 11 2022 update. When Microsoft launches the new Windows 11 operating system in 2021, it makes changes to File Explorer in several key areas. One of the most prominent changes is the introduction of a compact context menu, which File Explorer displays by default. Tip: Here are the instructions for restoring the classic File Explorer context menu in Windows 11. This change isn't the only one, as Microsoft simplified File Explorer's main toolbar, which resulted in many items only being accessible after an extra click or two. Hope Microsoft is around the corner

See all articles