Thread context switching

     The specific performance of the process state is determined by the registers of the CPU: the program counter (PC), the stack pointer (SP), the general-purpose registers, and the MMU (Memory Management Uinit) page table. These registers plus the contents of memory, disk files, and other peripherals. All this tells us everything about a computer. When a process needs to be switched, it is necessary to save all the CPU registers to the process structure of the process that switched out of the CPU, and then use the value of the CPU register saved in the process structure of the process that switched into the CPU to restore the CPU state. The principle of thread switching and context switching is similar, except that threads in the same address space do not need to switch such as MMU, but only need to switch necessary CPU registers. Therefore, thread switching is much faster than process switching.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326664996&siteId=291194637