简体   繁体   English

处理器如何知道以高优先级切换进程?

[英]How processor get to know to switch process with high prioirity process?

I red that, process scheduler will replace the process that is currently processing by cpu with high priority process. 我同意,进程调度程序将用高优先级进程替换cpu当前正在处理的进程。 At any point only one process will be executed by processor in that case where the scheduler is running to notify cpu about high priority process, when cpu is busy in executing low priority process ? 在这种情况下,当cpu忙于执行低优先级进程时,如果调度程序正在运行以通知cpu高优先级进程,则处理器将仅执行一个进程。

The process scheduler is the component of the operating system that is responsible for deciding whether the currently running process should continue running and, if not, which process should run next. 进程调度程序是操作系统的组件,负责确定当前正在运行的进程是否应该继续运行,如果不继续,则哪个进程应该继续运行。

To help the scheduler monitor processes and the amount of CPU time that they use, a programmable interval timer interrupts the processor periodically (typically 50 or 60 times per second) . 为了帮助调度程序监视processes及其使用的CPU时间, a programmable interval timer interrupts the processor periodically (typically 50 or 60 times per second) This timer is programmed when the operating system initializes itself. 操作系统初始化时,将对该计时器进行编程。 At each interrupt, the operating system's scheduler gets to run and decide whether the currently running process should be allowed to continue running or whether it should be suspended and another ready process allowed to run. 在每个中断处,操作系统的调度程序将开始运行,并决定是否应允许当前正在运行的进程继续运行,还是应将其暂停并允许另一个就绪进程运行。 This is the mechanism used for preemptive scheduling. 这是用于抢先式调度的机制。

So,basically,the process scheduler runs in the same main memory, when active , but are only activated after getting invoked by interrupts. 因此,基本上来说,进程调度程序在when active在相同的主内存中运行,但是只有在被中断调用后才被激活。 Hence,they aren't all time running. 因此,它们并非一直在运行。

BTW,that was a great conceptual question to answer.Best wishes for your topic. 顺便说一句,这是一个很好的概念性问题。

The higher-priority thread/process will preempt the lower-priority thread when an interrupt causes the scheduler to be run to decide on what set of threads to run next, and the scheduler algorithm decides that the lower-priority thread needs to be replaced by the higher-priority one. 当中断导致调度程序运行以决定下一步要运行的线程集,并且调度程序算法确定优先级较低的线程需要替换时,优先级较高的线程/进程将抢占优先级较低的线程。优先级较高的一个。

Interrupts come in two flavours: 中断有两种味道:

  1. Software interrupts, (syscalls) from threads that are already running and change the state of threads, eg. 软件中断,来自已经在运行的线程的(系统调用),并更改线程的状态,例如。 by signaling an event, mutex or semaphore upon which another thread is waiting, and so making it ready to run. 通过发信号通知另一个线程正在等待的事件,互斥或信号量,并使其准备好运行。

  2. Hardware interrupts that cause a driver to run and that driver chooses to invoke the scheduler on exit because an I/O operation has completed or some timeout interval has expired that needs to change the set of running threads, (eg. disk, NIC, KB, mouse, timer). 硬件中断导致驱动程序运行,并且该驱动程序选择退出时调用调度程序,因为I / O操作已完成或某个超时时间间隔已到期,需要更改正在运行的线程集(例如磁盘,NIC,KB) ,鼠标,计时器)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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