免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1978 | 回复: 6
打印 上一主题 下一主题

赫兹可以设置吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-09 16:52 |只看该作者 |倒序浏览
内核中
#define Hz 10000

赫兹意為每秒的週期性震動次數

不是应该由硬件晶振决定的吗,在代码里修改了这个值,会起到什么效果?

可以于晶振的实际值不一致吗?

论坛徽章:
0
2 [报告]
发表于 2009-10-09 20:25 |只看该作者
按我的理解, HZ是内核用来设置晶振器, 让它以HZ为频率来工作.

是内核来决定晶振器的工作频率, 而不是晶振器来决定内核代码中的HZ.

论坛徽章:
0
3 [报告]
发表于 2009-10-09 21:27 |只看该作者
内核的HZ和硬件HZ不是一个东西。

论坛徽章:
0
4 [报告]
发表于 2009-10-09 21:43 |只看该作者
个人理解:
cpu有自己的工作频率
hz是内核心跳,配合进程调度等工作。
如hz=100,则需要每10ms进行一次计时(jiffies++),也就是一次时钟中断,可在次中断中进行调度等工作。
假设cpu是100M Hz,会计算出,cpu每运算1M次就需要产生一次时钟中断。
你所说的晶振不知道说的是配合什么硬件工作的?
cpu?不知道现在的cpu还需要外接一个晶振吗?如果需要,这个晶振的频率也是固定的,不能改,也没有必要考虑。
RTC?这只是另外一个单独的计时硬件,提供一个标准始终而已。和hz没关系的,甚至和内核都没有多大关系。

修改hz只会影响内核调度粒度,具体的值随便你改,但是,太大占用资源,太小对性能有影响,一般不改。

论坛徽章:
0
5 [报告]
发表于 2009-10-10 12:36 |只看该作者
make menuconfig的时候可以配置,不过可选项有限。

论坛徽章:
0
6 [报告]
发表于 2009-10-10 17:35 |只看该作者

understand the linux kernel 3rd

Besides the Real Time Clock and the Time Stamp Counter, IBM-compatible PCs include another type of time-measuring device called Programmable Interval Timer(PIT).
The role of a PIT is similar to the alarm clock of a microwave oven: it makes the user aware that the cooking time interval has elapsed. Instead of ringing a bell,
this device issues a special interrupt called timer interrupt, which notifies the kernel that one more time interval has elapsed.[]
Another difference from the alarm clock is that the PIT goes on issuing interrupts forever at some fixed frequency established by the kernel. Each IBM-compatible PC includes at least one PIT, which is usually implemented by an 8254 CMOS chip using the 0x40-0x43 I/O ports.

As we'll see in detail in the next paragraphs, Linux programs the PIT of IBM-compatible PCs to issue timer interrupts on the IRQ 0 at a (roughly) 1000-Hz frequency that is, once every 1 millisecond. This time interval is called a tick, and its length in nanoseconds is stored in the tick_nsec variable.
On a PC, tick_nsec is initialized to 999,848 nanoseconds (yielding a clock signal frequency of about 1000.15 Hz), but its value may be automatically adjusted by the kernel if the computer is synchronized with an external clock (see the later section "The adjtimex( ) System Call"). The ticks beat time for all activities in the system; in some sense, they are like the ticks sounded by a metronome while a musician is rehearsing.



A few macros in the Linux code yield some constants that determine the frequency of timer interrupts. These are discussed in the following list.

HZ yields the approximate number of timer interrupts per second that is, their frequency. This value is set to 1000 for IBM PCs.

CLOCK_TICK_RATE yields the value 1,193,182, which is the 8254 chip's internal oscillator frequency.

LATCH yields the ratio between CLOCK_TICK_RATE and HZ, rounded to the nearest integer. It is used to program the PIT.

论坛徽章:
0
7 [报告]
发表于 2009-10-10 17:40 |只看该作者

编程的定时器

好象是说:用一种可编程的定时器来控制定时中断,
PC机上没有晶振吗?有的话,起什么作用? 上面那个定时器指的是晶振吗?

嵌入式设备上是不是就不同了呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP