03 | Basics: CPU context switches often said what that means (on)?

First, some context on why switch

1. What context switches?

Context switching task is to restore the staging and the current operating status

2. Why CPU to perform a context switch

When multiple processes competing for CPU, in order to ensure that each process can fairly be called CPU, the use of mechanisms to deal with the task time slice, when tasks on a time sheet to reach the final point in time, then the task is like hanging Since processing the next task, because the CPU processing speed is very fast, on the human perception considered parallel processing, it is actually a pseudo-parallel, only one task at the same time running process.

3, context switching the main consuming what resources, why not desirable context switch too many times?

Waste too much time on the switch, it will increase the time processing tasks, resulting delays, Caton phenomenon

4, divided into several context switch

Process context switching thread context switching, interrupt context switching

5, under what circumstances would trigger a context switch?

CPU time slice task of combing the depleted state transition process (like running, blocking), etc.

6. What is the biggest difference between the thread context switching and process context switch is?

A thread is the basic unit of scheduling, the process is the basic unit of resource owners.
Part of the process of switching to switch resources.
Thread belong to the same process, the occurrence of context switching, switching only private data threads, but the shared memory pool data has not changed, so fast.

7, the process of the thread context switching

1. Different processes between the thread context switching, the process is substantially the same, and a process context switch
2. The internal thread of the thread context switch, the user does not need the process of switching resources, only the switching of the thread private data line, a process context switch so than less consumption of resources, compared to multi-threaded multi-process quickly. Private data is what the data does not need to know.

Guess you like

Origin www.cnblogs.com/charon2/p/11762239.html