Clock interrupt mechanism of Linux OS kernel

Source: Internet
Author: User
Tags current time documentation time and date linux

Summary:

This paper mainly analyses the clock interrupt of Linux 2.4.0 kernel and the representation of kernel time from the point of kernel implementation. This article is written for readers and Linux driver developers who want to understand the Linux I/O subsystem.

Key words: Linux, clock, timer

Disclaimer: This document is published in the Spirit of free software open source code, and anyone can obtain, use and redistribute it free of charge, but you do not limit the right of others to redistribute the content you publish. The purpose of this article is to hope it will be useful to readers, but without warranty or even implied warranties for a particular purpose. For more information, refer to the GNU General Public License (GPL) and the GNU Free Documentation Agreement (GFDL).

You should have received a copy of the GNU General Public License (GPL) with the documentation. If not, write to: The Free Software Foundation, Inc., 675 Mass Ave, cambridge,ma02139, USA welcome you to point out the errors and questions in the documentation.

Objective

Time occupies an important position in an operating system kernel, which is a "pacemaker" that drives an OS kernel to run. Typically, the kernel requires two types of time:

1. Keep a record of the current time and date during the kernel run so that the kernel can make time markers (timestamp, also known as "timestamps") for certain objects and events, or for users to retrieve through time syscall.

2. Maintain a fixed cycle timer to remind the kernel or the user that a period of time has passed.

The time in the PC is provided by three kinds of clock hardware, and these clock hardware is based on the fixed frequency crystal oscillator to provide the clock square wave signal input. These three clock hardware are: (1) Real-time clock (real time CLOCK,RTC), (2) programmable interval timer (programmable Interval timer,pit), (3) timestamp counter (time Stamp COUNTER,TSC).

Clock hardware

1, Real Time clock RTC

Since IBM PC at, all PCs have included a clock chip called the Real Time Clock (RTC) to keep up with the time after the PC has been powered down. Obviously, the RTC is powered by a battery on the motherboard, not powered by a PC, so the RTC will continue to work when the PC is powered off. Typically, the CMOS RAM and RTC are integrated onto a chip, so the RTC is also called a "CMOS Timer." The most common RTC chips are MC146818 (Motorola) and DS12887 (Maxim), DS12887 fully compatible with MC146818 and have some extensions. This section is based primarily on the RTC chip of the MC146818 standard. Specific content can refer to MC146818 's datasheet.

1. 1 RTC Registers

The MC146818 RTC Chip has a total of 64 registers. Their chip internal address number is 0x00~ 0x3F (not I/O port address), these registers altogether can divide into three groups:

(1) clock and Calendar Register Group: A total of 10 (0x00~0x09), indicating time, calendar specific information. In PCs, the values in these registers are stored in the BCD format (such as 23dec= 0X23BCD).

(2) Status and Control Register Group: A total of 4 (0x0a~0x0d), control how the RTC chip works, and represents the current state.

(3) CMOS configuration data: Universal CMOS RAM, which has nothing to do with time, so we don't care about it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.