"processor time"的C99定义

C99 definition of "processor time"

C99 标准第 7.23.1 节第 1 段定义了几个 "time" 术语:

Many functions deal with a calendar time that represents the current date (according to the Gregorian calendar) and time. Some functions deal with local time, which is the calendar time expressed for some specific time zone, and with Daylight Saving Time, which is a temporary change in the algorithm for determining local time. The local time zone and Daylight Saving Time are implementation-defined.

但是,缺少“处理器时间”的定义。

C99 第 7.23.2.1 节第 2 段指出:

The clock function determines the processor time used.

什么是“处理器时间?” “处理器时间”是否在 C99 标准中定义;如果有,它是在哪里定义的?

根据 7.23.1:

The header < time.h > defines two macros ... NULL (described in 7.17); and

CLOCKS_PER_SEC

which expands to a constant expression with type clock_t (described below) that is the number per second of the value returned by the clock function.

因此,处理器时间必须表示 CLOCKS_PER_SEC 中测量的 clock_t 值,因为规范将其定义为调用 clock 的结果,而其他地方使用术语 'processor time' 作为该结果的名称。

标准没有定义短语 "processor time"。它在正常的技术英语意义上使用它。

该标准在第 2 节中包含规范性参考文献列表,其中之一是:

  • ISO/IEC 2382−1:1993, 信息技术——词汇——第 1 部分:基本术语。

如果该文档定义了 "processor time",那么这就是标准使用的定义。我不知道它是否存在,因为我无权访问该文档。

但想法是 "processor time" 是 CPU 使用的类型数量,不包括睡眠或等待某些事件(例如 I/O 完成)所花费的时间要求。例如,从键盘读取一行输入的程序可能会消耗 "wall-clock time" 的 60 秒(如果用户用这么长时间来响应),但只占用处理器时间的几分之一秒。通常经过的处理器时间将小于经过的 "wall clock" 时间,但如果程序运行多个 CPU 秒,它可能会更长。

顺便说一下,这个措辞在 C90、C99 和 C11 中没有显着变化。