简体   繁体   中英

How does the OS keep interrupted process always running on specified CPU?

I know an interrupt can come anytime and broke the execution of current process context. But I just wonder when the interrupt handle is finished, how the OS, such as Linux , can keep current interrupted process still running on this local CPU, and won't be scheduled to other CPUs?

An interrupt is handled by the executing process. If Fred's process is running while the CPU gets an interrupt caused by Bill's process reading this disk, Fred's process handles Bill's interrupt. After the interrupt handler is finished, it executes an INTERRUPT RETURN instruction (exact name varies among systems) and the Fred's process picks up where it was when it was interrupted.

The running process keeps running throughout the interrupt. It is the process's instruction stream that is interrupted; not that the process is interrupted with another.

However, it is possible that the interrupt handler could cause a context switch to another process.

In linux kernel which is turned on CONFIG_PREEMPT, after an interrupt handler finish, there are two choices. One is the process which ran before interrupt keeps running written by user3344003. The other is the scheduler can choose another process instead of the process.(_TIF_NEED_RESCHED)

If CONFIG_PREEMPT is disabled, the process which ran before interrupt always keep running.

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