The cycle rate of Linux source analysis--param.h

Source: Internet
Author: User

The system timer frequency is defined by static preprocessing, and the hardware is set according to the HZ value at system startup. The value of Hz differs depending on the architecture. For some architectures, even machines, the value of Hz is different.
The kernel defines the value of HZ in <asm/param.h>. We will then compare the specific source code:

1. ARM Architecture (file path:/arm/include/asm/param.h)

#ifndef __asm_param_h#define __asm_param_h#ifdef __kernel__# define HZ             config_hz/       * Internal KERNEL Timer  Frequency */# define USER_HZ             /* USER interfaces is in "ticks" */# define CLOCKS_PER_SEC (user_hz)/       * like Times () */#else # define HZ             100#endif#define exec_pagesize   4096#ifndef nogroup#define nogroup         ( -1) #endif/ * Max length of hostname */#define Maxhostnamelen  64#endif

As you can see, in the ARM architecture, the default value of the system timer frequency is 100, that is, the frequency at which the time is interrupted is at + HZ.

2. x86 Architecture (file path:/x86/include/asm/param.h)

#include <asm-generic/param.h> file path:/include/asm-generic/param.h#ifndef __asm_generic_param_h#define __asm_ Generic_param_h#ifndef hz#define HZ 100#endif#ifndef exec_pagesize#define exec_pagesize   4096#endif#ifndef Nogroup#define nogroup         ( -1) #endif # define Maxhostnamelen/      * max length of hostname */#endif/* __asm_ Generic_param_h * *

As you can see, in the x86 architecture, the system timer frequency defaults to 100, which is the frequency at which the time is interrupted.

3. Alpha (file path:/alpha/include/asm/param.h)
#ifndef _asm_alpha_param_h#define _asm_alpha_param_h#ifdef __kernel__#define Hz              config_hz#define USER_HZ         Hz #else # define HZ              1024#endif#define exec_pagesize   8192#ifndef nogroup#define nogroup         ( -1) #endif # define Maxhostnamelen      */MAX length of hostname */#ifdef __kernel__# define CLOCKS_PER_SEC HZ/      * Frequency at whic H times () counts */#endif #endif/* _asm_alpha_param_h */

As you can see, the Alpha model has a beat rate of 1024.

Summarize:
Comparing the three different architectures, the value of Hz will change depending on the architecture. The higher the beat rate, not only can improve the accuracy of time-driven, but also improve the resolution of time-driven events; but this means that the more processor time the interrupt handler consumes, the heavier the system is.
In addition, the value of HZ is not fixed, and the beat rate is adjustable for most architectures. When the kernel is compiled with the CONFIG_HZ option set, the system does not trigger clock interrupts at regular intervals, but instead dynamically dispatches clock interrupts based on this option. For systems without beats, interrupts are not interrupted unnecessarily during idle time, which helps to reduce system overhead, which saves energy and achieves power saving.

The cycle rate of Linux source analysis--param.h

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.