哪些进程状态会影响服务器的平均负载?

What process states contribute to the load average of a server?

这是一个面试问题,我参加了 phone 筛选。

我给出的答案是: Running State (R)interruptible State (S)IO wait.

但我想我可能理解错了问题或者我的回答中可能缺少某些东西我只是觉得。

所以我在网上查了一下,发现了一些愚蠢的零散信息。我仍然不确定答案是什么。

你觉得这个问题的答案怎么样?

没有计算平均负载的标准方法,这取决于 OS。这里是 Linux's load calculator:

long calc_load_fold_active(struct rq *this_rq)
{
    long nr_active, delta = 0;

    nr_active = this_rq->nr_running;
    nr_active += (long) this_rq->nr_uninterruptible;

    if (nr_active != this_rq->calc_load_active) {
        delta = nr_active - this_rq->calc_load_active;
        this_rq->calc_load_active = nr_active;
    }

    return delta;
}

出于平均负载的目的,进程 Linux 被视为活动进程是 运行 (R) 和 Uininterruptible (D)。

Interruptible Sleep (S) 不计入,Defunct (Z) 或 Stopped (T) 也不计入。