Clock interruption mechanism in Linux Kernel

Source: Internet
Author: User
Clock interruption mechanism of Linux operating system kernel-Linux general technology-Linux programming and kernel information. The following is a detailed description. Abstract:

This article mainly analyzes the clock interruption and Kernel Time Representation of Linux 2.4.0 kernel from the perspective of kernel implementation. This article is intended for readers and Linux driver developers who want to understand the Linux I/O subsystem.

Note: This document is released in the spirit of free software open source code. Anyone can obtain, use, and re-release it for free, but you have no right to restrict others from re-publishing your content. The purpose of this article is to hope that it can be useful to readers, but it does not have any guarantees, or even implicit guarantees suitable for a specific purpose. For more details, see the GNU General Public License (GPL) and the GNU Free Documentation protocol (GFDL ).

You should have received a copy of the GNU General Public License (GPL) together with the document. If not, write to: The Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA02139, USA. You are welcome to point out The errors and questions in this document.

Preface

Time plays an important role in an operating system kernel. It is the "starter" that drives an operating system kernel ". Generally, the kernel requires two types of time:

1. the current time and date are continuously recorded during kernel running, so that the kernel can mark some objects and events with time (timestamp, also known as "timestamp "), or you can use the time syscall for retrieval.

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

The time in the PC is provided by three clock hardware, which are based on fixed frequency crystal oscillator to provide clock square wave signal input. The three Clock hardware types are: (1) Real-Time Clock (RTC); (2) Programmable Interval Timer (Programmable Interval Timer, PIT); (3) time Stamp Counter (TSC ).

Clock hardware 7.1

7.1.1 real-time clock RTC

Since ibm pc at, all PCs have included a clock chip called real-time clock (RTC), so that the PC can continue to maintain time after power failure. Apparently, RTC is powered by a battery on the motherboard, rather than by a PC, so when the PC turns off the power, RTC will continue to work. Generally, cmos ram and RTC are integrated into one chip, so RTC is also called "CMOS Timer ". The most common RTC chips are MC146818 (Motorola) and DS12887 (maxim). DS12887 is fully compatible with MC146818 and has certain extensions. This section is mainly based on the standard RTC chip MC146818. For more information, see Datasheet of MC146818.

7.1.1.1 RTC register

The MC146818 RTC chip has a total of 64 registers. Their internal chip address numbers are 0x00 ~ 0x3F (not the I/O port address), these registers can be divided into three groups:

(1) clock and calendar register group: a total of 10 (0x00 ~ 0x09), indicating the specific time and calendar information. In a PC, the values in these registers are stored in BCD format (for example, 23dec = 0x23BCD ).

(2) Status and control register group: there are 4 (0x0A ~ 0x0D), controls how the RTC chip works, and indicates the current status.

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

The clock and calendar register groups are described as follows:
QUOTE:
Related Article

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.