高优先级任务到来时如何调用调度程序

时间:2021-05-30 02:29:33

I have read here about situations where a scheduler is called. But what happens when a high priority task comes?

我在这里读到了调用调度程序的情况。但是当高优先级任务到来时会发生什么?

3 个解决方案

#1


1  

High priority tasks are scheduled more often than low priority tasks but when a high priority task comes it still has to wait until the quantum of the running task is over.

高优先级任务比低优先级任务更频繁地安排,但是当高优先级任务到来时,它仍然必须等到正在运行的任务的量程结束。

#2


0  

Priority changes and is adjusted based on past CPU usage.

优先级更改,并根据过去的CPU使用情况进行调整。

The longer version

版本较长

In Linux, process priority is dynamic. The scheduler keeps track of what processes are doing and adjusts their priorities periodically; in this way, processes that have been denied the use of the CPU for a long time interval are boosted by dynamically increasing their priority. Correspondingly, processes running for a long time are penalized by decreasing their priority.

在Linux中,进程优先级是动态的。调度程序会跟踪正在执行的进程并定期调整其优先级;以这种方式,通过动态地增加它们的优先级来提高已被拒绝长时间间隔使用CPU的进程。相应地,长时间运行的进程通过降低其优先级而受到惩罚。

#3


0  

Scheduler maintains a set of all tasks that are ready to run in the system. In a multi-priority system, the task set usually supports the notion of priority. When a high priority task arrives in the system, it is put into the set of tasks sorted by priority.

调度程序维护一组准备好在系统中运行的所有任务。在多优先级系统中,任务集通常支持优先级概念。当高优先级任务到达系统时,它将被放入按优先级排序的任务集中。

There are certain points in the kernel where we check if a better process is available to run, compared to the currently running process. This can happen when the time slice expires OR when the ISR is done OR when a lock is unlocked, etc. Look for calls to switch() OR _switch() or something similar...this is the routine that checks the set of tasks and determines if the current task is the highest prio.

在内核中,我们检查是否有更好的进程可用于运行,与当前运行的进程相比。这可能发生在时间片到期或ISR完成时或解锁时等等。查找调用switch()或_switch()或类似的东西......这是检查任务集的例程并确定当前任务是否是最高的prio。

If the current task is not the highest prio task, then the current task is switched out and the highest prio task is obtained from the task set and scheduled to run.

如果当前任务不是最高prio任务,则切换当前任务并从任务集中获取最高prio任务并计划运行。

#1


1  

High priority tasks are scheduled more often than low priority tasks but when a high priority task comes it still has to wait until the quantum of the running task is over.

高优先级任务比低优先级任务更频繁地安排,但是当高优先级任务到来时,它仍然必须等到正在运行的任务的量程结束。

#2


0  

Priority changes and is adjusted based on past CPU usage.

优先级更改,并根据过去的CPU使用情况进行调整。

The longer version

版本较长

In Linux, process priority is dynamic. The scheduler keeps track of what processes are doing and adjusts their priorities periodically; in this way, processes that have been denied the use of the CPU for a long time interval are boosted by dynamically increasing their priority. Correspondingly, processes running for a long time are penalized by decreasing their priority.

在Linux中,进程优先级是动态的。调度程序会跟踪正在执行的进程并定期调整其优先级;以这种方式,通过动态地增加它们的优先级来提高已被拒绝长时间间隔使用CPU的进程。相应地,长时间运行的进程通过降低其优先级而受到惩罚。

#3


0  

Scheduler maintains a set of all tasks that are ready to run in the system. In a multi-priority system, the task set usually supports the notion of priority. When a high priority task arrives in the system, it is put into the set of tasks sorted by priority.

调度程序维护一组准备好在系统中运行的所有任务。在多优先级系统中,任务集通常支持优先级概念。当高优先级任务到达系统时,它将被放入按优先级排序的任务集中。

There are certain points in the kernel where we check if a better process is available to run, compared to the currently running process. This can happen when the time slice expires OR when the ISR is done OR when a lock is unlocked, etc. Look for calls to switch() OR _switch() or something similar...this is the routine that checks the set of tasks and determines if the current task is the highest prio.

在内核中,我们检查是否有更好的进程可用于运行,与当前运行的进程相比。这可能发生在时间片到期或ISR完成时或解锁时等等。查找调用switch()或_switch()或类似的东西......这是检查任务集的例程并确定当前任务是否是最高的prio。

If the current task is not the highest prio task, then the current task is switched out and the highest prio task is obtained from the task set and scheduled to run.

如果当前任务不是最高prio任务,则切换当前任务并从任务集中获取最高prio任务并计划运行。