2

据我了解,调度程序在线程上执行抢占之前的默认时间约为 100 毫秒,这个量如何随繁忙线程的数量(需要进行上下文切换)而变化?

如果有 200 个线程在运行,其中 100 个线程使用约 100 毫秒,那么另外 100 个线程不会那么高兴。有没有像完整线程循环时间这样的实体?量子是基于女巫的吗?

我想到了 Linux 3.2+ 内核。

4

1 回答 1

1

The CFS approach is that each process would receive 1/n of the processor's time. It has a targeted latency. It is the time in which every process would receive a chance to execute some code.

To approach this, scheduler runs a process for a specified amount of time which called timeslice. Typically timeslice is targeted latency divided by number of running processes.

But when number of running processes aprroaches infinity, timeslice approaches zero. As this will eventually result in unacceptable switching costs, CFS imposes a floor on the timeslice assigned to each process.This floor is called the minimum granularity. By default it is 1 millisecond. Thus, even as the number of runnable processes approaches infinity, each will run for at least 1 millisecond, to ensure there is a ceiling on the incurred switching costs.

于 2013-07-01T21:56:03.000 回答