Analysis of time programming and realization principle in Linux (ii) Details of hardware and glibc libraries

Source: Internet
Author: User

Introduction

After familiar with the basic programming method, our interest lies in how does the computer achieve all this? What does the operating system and the library function do between the application-layer APIs and the underlying system hardware?

First look at the general process of Linux time processing:

Figure 1. Time processing process

The application section has been covered in detail in the first section, and in the second part I will introduce some general overviews of hardware and GlibC related implementations.

Hardware

The most common clock hardware in a PC is the following.

RTC (Real time Clock, live clock)

When people need to know the time, they can look at the clocks. The hardware of a clock in a computer system is an external clock. It relies on the battery on the motherboard to maintain the accuracy of the clock when the system is powered down. When the computer needs to know the time, it needs to read the clock.

In the x86 system, this clock is generally called real time Clock. The RTC is a CMOS chip on the motherboard, such as Motorola 146818, which is independent of the CPU and other chips and can operate the RTC through the 0x70 and 0x71 ports. The RTC can periodically trigger interrupts on IRQ 8, but with low precision, from 2HZ to 8192HZ.

In the case of Motorola 146818, the software can read and write the following values through the I/O instruction:

Figure 2. Motorola 146818

As you can see, the RTC can provide real-time time values that are accurate to seconds.

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.