简体   繁体   中英

Context switch of a process and memory changes

I don't understand the context switch full operations.

When a running process A go to ready/blocked status in favour of another process B because of scheduler, the dispatcher saves A's PSW and GPR in its PCB and stores B's PSW and GPR into CPU. So the PCB's queues are updated.

What about the frames used by the process A (code/data/stack)? Are they swapped into swap area or remain into memory?

The A's page table is still in memory? Is the page table of a process saved into memory when the process is created? Or when it goes to running status?

What about A's open files table?

I want to understand the accurate operations of a process context switch because it's important to see the differences between the speed context switch of threads and the heavy one of processes.

This is all system specific. At the hardware a level, a context switch generally just saves registers to a context block and reads registers from another context block.

The page tables for the inactive process may or may not remain in memory. It's all up to the memory management of the operating system. Usually, an operating system would leave them in physical memory until that memory was needed for something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM