【发布时间】:2018-12-17 14:07:21
【问题描述】:
我正在阅读来自cpufreq_governor.h 的一些内核源代码并看到了这个:
/*
* The polling frequency depends on the capability of the processor. Default
* polling frequency is 1000 times the transition latency of the processor. The
* governor will work on any processor with transition latency <= 10ms, using
* appropriate sampling rate.
*
* For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL)
* this governor will not work. All times here are in us (micro seconds).
*/
#define MIN_SAMPLING_RATE_RATIO (2)
#define LATENCY_MULTIPLIER (1000)
#define MIN_LATENCY_MULTIPLIER (20)
#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
将最后一行改为阅读不是更有效吗:
#define TRANSITION_LATENCY_LIMIT (10000000) /* (10 * 1000 * 1000) */
【问题讨论】:
-
仅出于可读性考虑,最好保持原样。 (只是我的看法。),我的眼睛看到和理解
10 * 1000 * 1000比10000000更快。 -
作为记录,标准的相关部分是这样的:c0x.coding-guidelines.com/6.6.html 注意它说的是“可以”,而不是“必须”在“翻译”(即编译)时评估。跨度>
-
这里要注意的另一件事是编译器必须能够在编译时elsewhere(整数常量表达式)计算10 * 1000 * 1000,所以它没有在这种情况下这样做是很愚蠢的。
标签: c c-preprocessor