include/linux/jiffies.h
Source file repositories/reference/linux-study-clean/include/linux/jiffies.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/jiffies.h- Extension
.h- Size
- 21834 bytes
- Lines
- 659
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cache.hlinux/limits.hlinux/math64.hlinux/minmax.hlinux/types.hlinux/time.hlinux/timex.hvdso/jiffies.hasm/param.hgenerated/timeconst.h
Detected Declarations
struct ctl_tablefunction get_jiffies_64function valuesfunction jiffies_to_usecsfunction jiffies_to_nsecsfunction _msecs_to_jiffiesfunction _msecs_to_jiffiesfunction _msecs_to_jiffiesfunction _msecs_to_jiffiesfunction _usecs_to_jiffiesfunction _usecs_to_jiffiesfunction usecs_to_jiffiesfunction jiffies_delta_to_clock_tfunction jiffies_delta_to_msecs
Annotated Snippet
#ifndef _LINUX_JIFFIES_H
#define _LINUX_JIFFIES_H
#include <linux/cache.h>
#include <linux/limits.h>
#include <linux/math64.h>
#include <linux/minmax.h>
#include <linux/types.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <vdso/jiffies.h>
#include <asm/param.h> /* for HZ */
#include <generated/timeconst.h>
/*
* 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
/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can
* improve accuracy by shifting LSH bits, hence calculating:
* (NOM << LSH) / DEN
* This however means trouble for large NOM, because (NOM << LSH) may no
* longer fit in 32 bits. The following way of calculating this gives us
* some slack, under the following conditions:
* - (NOM / DEN) fits in (32 - LSH) bits.
* - (NOM % DEN) fits in (32 - LSH) bits.
*/
#define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \
+ ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))
/* LATCH is used in the interval timer and ftape setup. */
#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
extern void register_refined_jiffies(long clock_tick_rate);
/* TICK_USEC is the time between ticks in usec */
#define TICK_USEC ((USEC_PER_SEC + HZ/2) / HZ)
/* USER_TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
#define USER_TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
/*
* The 64-bit value is not atomic on 32-bit systems - you MUST NOT read it
* without sampling the sequence number in jiffies_lock.
* get_jiffies_64() will do this for you as appropriate.
*
* jiffies and jiffies_64 are at the same address for little-endian systems
* and for 64-bit big-endian systems.
* On 32-bit big-endian systems, jiffies is the lower 32 bits of jiffies_64
* (i.e., at address @jiffies_64 + 4).
* See arch/ARCH/kernel/vmlinux.lds.S
*/
extern u64 __cacheline_aligned_in_smp jiffies_64;
extern unsigned long volatile __cacheline_aligned_in_smp jiffies;
#if (BITS_PER_LONG < 64)
u64 get_jiffies_64(void);
#else
/**
* get_jiffies_64 - read the 64-bit non-atomic jiffies_64 value
*
* When BITS_PER_LONG < 64, this uses sequence number sampling using
* jiffies_lock to protect the 64-bit read.
Annotation
- Immediate include surface: `linux/cache.h`, `linux/limits.h`, `linux/math64.h`, `linux/minmax.h`, `linux/types.h`, `linux/time.h`, `linux/timex.h`, `vdso/jiffies.h`.
- Detected declarations: `struct ctl_table`, `function get_jiffies_64`, `function values`, `function jiffies_to_usecs`, `function jiffies_to_nsecs`, `function _msecs_to_jiffies`, `function _msecs_to_jiffies`, `function _msecs_to_jiffies`, `function _msecs_to_jiffies`, `function _usecs_to_jiffies`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.