• Home
  • Raw
  • Download

Lines Matching +full:system +full:- +full:clock +full:- +full:frequency

1 Clock sources, Clock events, sched_clock() and delay timers
2 -----------------------------------------------------------
9 If you grep through the kernel source you will find a number of architecture-
10 specific implementations of clock sources, clockevents and several likewise
11 architecture-specific overrides of the sched_clock() function and some
14 To provide timekeeping for your platform, the clock source provides
15 the basic timeline, whereas clock events shoot interrupts on certain points
16 on this timeline, providing facilities such as high-resolution timers.
21 Clock sources
22 -------------
24 The purpose of the clock source is to provide a timeline for the system that
26 a Linux system will eventually read the clock source to determine exactly
29 Typically the clock source is a monotonic, atomic counter which will provide
30 n bits which count from 0 to (2^n)-1 and then wraps around to 0 and start over.
31 It will ideally NEVER stop ticking as long as the system is running. It
32 may stop during system suspend.
34 The clock source shall have as high resolution as possible, and the frequency
35 shall be as stable and correct as possible as compared to a real-world wall
36 clock. It should not move unpredictably back and forth in time or miss a few
45 When the wall-clock accuracy of the clock source isn't satisfactory, there
47 the user-visible time to RTC clocks in the system or against networked time
49 the clock source, which provides the fundamental timeline for the system.
50 These measures does not affect the clock source per se, they only adapt the
51 system to the shortcomings of it.
53 The clock source struct shall provide means to translate the provided counter
62 You will find a number of helper functions in the clock source code intended
67 factors using the frequency of the clock source as the only input.
69 For real simple clock sources accessed from a single I/O memory location
72 register counts up or down, and the timer clock rate, and then conjure all
75 Since a 32-bit counter at say 100 MHz will wrap around to zero after some 43
76 seconds, the code handling the clock source will have to compensate for this.
77 That is the reason why the clock source struct also contains a 'mask'
80 compensation code on both sides of the wrap point so that the system timeline
84 Clock events
85 ------------
87 Clock events are the conceptual reverse of clock sources: they take a
91 Clock events are orthogonal to clock sources. The same hardware
92 and register range may be used for the clock event, but it is essentially
93 a different thing. The hardware driving clock events has to be able to
94 fire interrupts, so as to trigger events on the system timeline. On an SMP
95 system, it is ideal (and customary) to have one such event driving timer per
99 You will notice that the clock event device code is based on the same basic
102 assigning these values. The clock event driver does not need a 'mask'
103 attribute however: the system will not try to plan events beyond the time
104 horizon of the clock event.
108 -------------
110 In addition to the clock sources and clock events there is a special weak
112 number of nanoseconds since the system was started. An architecture may or
114 implementation is not provided, the system jiffy counter will be used as
117 As the name suggests, sched_clock() is used for scheduling the system,
122 Compared to clock sources, sched_clock() has to be very fast: it is called
123 much more often, especially by the scheduler. If you have to do trade-offs
124 between accuracy compared to the clock source, you may sacrifice accuracy
126 characteristics as the clock source, i.e. it should be monotonic.
134 jiffy frequency for the architecture. This will affect scheduling accuracy
135 and will likely show up in system benchmarks.
137 The clock driving sched_clock() may stop or reset to zero during system
139 events on the system. However it may result in interesting timestamps in
142 The sched_clock() function should be callable in any context, IRQ- and
143 NMI-safe and return a sane value in any context.
146 counter to derive a 64-bit nanosecond value, so for example on the ARM
148 sched_clock() nanosecond base from a 16- or 32-bit counter. Sometimes the
149 same counter that is also used as clock source is used for this purpose.
154 drift between the CPUs on the system. The kernel can work around this by
156 that makes sched_clock() different from the ordinary clock source.
160 --------------------------------------
162 On systems with variable CPU frequency, the various kernel delay() functions
167 Let's hope that your system is running on maximum frequency when this value
168 is calibrated: as an effect when the frequency is geared down to half the
169 full frequency, any delay() will be twice as long. Usually this does not
173 Enter timer-based delays. Using these, a timer read may be used instead of
174 a hard-coded loop for providing the desired delay.