Chinaunix首页 | 论坛 | 博客

分类: LINUX

2011-10-06 22:24:43

Countless computerized activities are driven by timing measurements , often behind the user's back. For instance, if the screen is automatically switched off after you have stopped using the computer's console, it is due to a timer that allows the kernel to keep track of how much time has elapsed since you pushed a key or moved the mouse. If you receive a warning from the system asking you to remove a set of unused files, it is the outcome of a program that identifies all user files that have not been accessed for a long time. To do these things, programs must be able to retrieve a timestamp identifying its last access time from each file. Such a timestamp must be automatically written by the kernel. More significantly, timing drives process switches along with even more visible kernel activities such as checking for time-outs.
数不尽的计算机活动都是用时间测量来驱使的,一般在用户可视范围外。举例说,如果监视器自动关闭在你停止用计算机终端,这是因为一个计时器允许kernel跟踪你不输入一个键或者不动鼠标多少时间流逝了。如果你接到一个系统警告,让你去删除一些不用的一些文件,这是因为程序发现这些很久没有使用的用户文件。为了做这些事情,程序必须能接受时间戳来识别最后一次使用各个文件的时间。这样的时间戳必须由kernel来写。更重要的是,计时器驱动程序和更加可视化的内核之间切换,如:检查超时。
We can distinguish two main kinds of timing measurement that must be performed by the Linux kernel:
  我们可以区分两个主要的被linux kernel运行时间管理
Keeping the current time and date so they can be returned to user programs through the time( ), ftime( ), and gettimeofday( ) APIs (see the section "The time( ) and gettimeofday( ) System Calls" later in this chapter) and used by the kernel itself as timestamps for files and network packets
   保持当前时间和日期可以让用户进程来通过调用time() , ftime(), gettimeofday()API系统调用和让内核自己来当作文件或者网络包的时间戳。
Maintaining timers mechanisms that are able to notify the kernel (see the later section "Software Timers and Delay Functions") or a user program (see the later sections "The setitimer( ) and alarm( ) System Calls" and "System Calls for POSIX Timers") that a certain interval of time has elapsed
  保持计时器来提醒kernel或者用户进程一段流逝时间间隔的机制(件后面的软件计时器和延迟函数kernel)(看后面的settimer()和alarm()系统调用 和 系统调用posix计时器)
 Timing measurements are performed by several hardware circuits based on fixed-frequency oscillators and counters. This chapter consists of four different parts. The first two sections describe the hardware devices that underly timing and give an overall picture of Linux timekeeping architecture. The following sections describe the main time-related duties of the kernel: implementing CPU time sharing, updating system time and resource usage statistics, and maintaining software timers. The last section discusses the system calls related to timing measurements and the corresponding service routines.
  计时器方法让一些硬件基于固定频率的晶体振荡器和计数器的周期。这一章包含4主要的部分。前两节描述底层的计时器硬件设备然后给出一张linux 时间保持的架构。接下来的两部分描述了主要的和时间有关的kernel 职责: 完成cpu的时间共享,更新系统时间、资源用户数据和维持软件计数器。最后一节讨论和时间测量有关的系统调用,和有关的服务例程。

阅读(790) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~