jiffies 和 jiffies_64 的联系与区别

HZ  和 CONFIG_HZ 宏定义的位置:

实际上在 linux-2.6.x/include/asm/param.h  定义了HZ的值:

 

/*
 *  arch/arm/include/asm/param.h
 *
 *  Copyright (C) 1995-1999 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __ASM_PARAM_H
#define __ASM_PARAM_H

 

#ifdef __KERNEL__


# define HZ     CONFIG_HZ                   /* Internal kernel timer frequency */
# define USER_HZ    100                     /* User interfaces are 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

 

 CONFIG_HZ的值可以在make menuconfig时设置,表示每秒钟定时器发生中断的次数,默认值是250。

 

 

jiffies位于 include/linux/jiffies.h 文件当中:

 

#ifndef _LINUX_JIFFIES_H
#define _LINUX_JIFFIES_H

#include <linux/math64.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <asm/param.h>          /* for HZ */

/*
 * The following defines establish the engineering parameters of the PLL
 * model. The HZ variable establishes the timer interrupt frequency, 100 Hz
 * for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the
 * OSF/1 kernel. The SHIFT_HZ define expresses the same value as the
 * nearest power of two in order to avoid hardware multiply operations.
 */
#if HZ >= 12 && HZ < 24
# define SHIFT_HZ   4
#elif HZ >= 24 && HZ < 48
# define SHIFT_HZ   5
#elif HZ >= 48 && HZ < 96
# define SHIFT_HZ   6
#elif HZ >= 96 && HZ < 192
# define SHIFT_HZ   7
#elif HZ >= 192 && HZ < 384
# define SHIFT_HZ   8
#elif HZ >= 384 && HZ < 768
# define SHIFT_HZ   9
#elif HZ >= 768 && HZ < 1536
# define SHIFT_HZ   10
#elif HZ >= 1536 && HZ < 3072
# define SHIFT_HZ   11
#elif HZ >= 3072 && HZ < 6144
# define SHIFT_HZ   12
#elif HZ >= 6144 && HZ < 12288
# define SHIFT_HZ   13
#else
# error Invalid value of HZ.
#endif

 

…………

/* some arch's have a small-data section that can be accessed register-relative
 * but that can only take up to, say, 4-byte variables. jiffies being part of
 * an 8-byte variable may not be correctly accessed unless we force the issue
 */
#define __jiffy_data  __attribute__((section(".data")))

/*
 * The 64-bit value is not atomic - you MUST NOT read it
 * without sampling the sequence number in xtime_lock.
 * get_jiffies_64() will do this for you as appropriate.
 */
extern u64 __jiffy_data jiffies_64;
extern unsigned long volatile __jiffy_data jiffies;

#if (BITS_PER_LONG < 64)
u64 get_jiffies_64(void);
#else
static inline u64 get_jiffies_64(void)
{
    return (u64)jiffies;
}
#endif

/*
 *  These inlines deal with timer wrapping correctly. You are
 *  strongly encouraged to use them
 *  1. Because people otherwise forget
 *  2. Because if the timer wrap changes in future you won't have to
 *     alter your driver code.
 *
 * time_after(a,b) returns true if the time a is after time b.
 *
 * Do this with "<0" and ">=0" to only test the sign of the result. A
 * good compiler would generate better code (and a really good compiler
 * wouldn't care). Gcc is currently neither.
 */
#define time_after(a,b)     \
    (typecheck(unsigned long, a) && \
     typecheck(unsigned long, b) && \
     ((long)(b) - (long)(a) < 0))
#define time_before(a,b)    time_after(b,a)

#define time_after_eq(a,b)  \
    (typecheck(unsigned long, a) && \
     typecheck(unsigned long, b) && \
     ((long)(a) - (long)(b) >= 0))
#define time_before_eq(a,b) time_after_eq(b,a)

/*
 * Calculate whether a is in the range of [b, c].
 */
#define time_in_range(a,b,c) \

…………


你可能感兴趣的:(linux,timer,user,gcc,Parameters,compiler)