ktime_t type defined in the
include/linux/ktime.h file provides a nanosecond-resolution
representation of kernel time values, though time keeping may be done at
coarser time-scales (e.g., at the granularity with which the jiffy is configured).
kernel/time/hrtimer.c file implements a high resolution timers subsystem that is the
basis for high resolution kernel timers as well as most current userspace timer iterfaces:
nanosleep, and POSIX timers.
kernel/time/tick-common.c file defines functions for generating and handling tick events, including the
tick_periodic function for periodic tick systems.
kernel/time/tick-oneshot.c file defines functions for oneshot ticks.
kernel/time/tick-broadcast.c file defines functions for handling
the broadcast of tick events for SMP systems, including functions for
handling ticks in oneshot mode.
kernel/time/timekeeping.c file several functions
for accessing, measuring, and setting time in the Linux kernel,
including several functions which return or take as parameters
variables of the
kernel/time/time.c file defines basic time related system calls:
time, which measure calendar time (a.k.a. real world time);
settimeofday, which updates the system clock; etc.
include/uapi/linux/time.hfile defines IDs for the different system clocks according to the POSIX clocks API, which is intended to improve portability across different Unix variants. As is noted on pages 491-492 of the LPI text book:
CLOCK_REALTIMEis a settable system wide clock for real-world-time.
CLOCK_MONOTONICis a non-settable non-decreasing clock that measures time since system startup.
CLOCK_PROCESS_CPUTIME_IDtracks the CPU time used by a process.
CLOCK_THREAD_CPUTIME_IDtracks the CPU time used by a thread.
CLOCK_MONOTONIC_RAWis a non-settable non-decreasing clock that is not affected by network time protocol (NTP) adjustments (and may be used for clock synchronization).
CLOCK_MONOTONIC_COARSEare lower resolution versions of the
kernel/time/posix-timers.c file defines key system calls for the POSIX clocks API:
clock_getres for obtaining the time and resolution of a given clock; and
clock_settime that a privileged process can use to set the
kernel/time/timer.c file implements a legacy timer subsystem based on
timer wheels, which is provided for backward compatibility with older versions of Linux.