Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20452
b: refs/heads/master
c: 726c14b
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mackerras authored and Linus Torvalds committed Feb 17, 2006
1 parent 74026cf commit 0a318bd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dd942ae331425812930cd01766178b7e28e65f2d
refs/heads/master: 726c14bf499e91e7ede4f1728830aba05c675061
3 changes: 3 additions & 0 deletions trunk/include/linux/timex.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ time_interpolator_reset(void)

#endif /* !CONFIG_TIME_INTERPOLATION */

/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */
extern u64 current_tick_length(void);

#endif /* KERNEL */

#endif /* LINUX_TIMEX_H */
39 changes: 34 additions & 5 deletions trunk/kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,16 @@ static void second_overflow(void)
#endif
}

/* in the NTP reference this is called "hardclock()" */
static void update_wall_time_one_tick(void)
/*
* Returns how many microseconds we need to add to xtime this tick
* in doing an adjustment requested with adjtime.
*/
static long adjtime_adjustment(void)
{
long time_adjust_step, delta_nsec;
long time_adjust_step;

if ((time_adjust_step = time_adjust) != 0 ) {
time_adjust_step = time_adjust;
if (time_adjust_step) {
/*
* We are doing an adjtime thing. Prepare time_adjust_step to
* be within bounds. Note that a positive time_adjust means we
Expand All @@ -733,10 +737,19 @@ static void update_wall_time_one_tick(void)
*/
time_adjust_step = min(time_adjust_step, (long)tickadj);
time_adjust_step = max(time_adjust_step, (long)-tickadj);
}
return time_adjust_step;
}

/* in the NTP reference this is called "hardclock()" */
static void update_wall_time_one_tick(void)
{
long time_adjust_step, delta_nsec;

time_adjust_step = adjtime_adjustment();
if (time_adjust_step)
/* Reduce by this step the amount of time left */
time_adjust -= time_adjust_step;
}
delta_nsec = tick_nsec + time_adjust_step * 1000;
/*
* Advance the phase, once it gets to one microsecond, then
Expand All @@ -758,6 +771,22 @@ static void update_wall_time_one_tick(void)
}
}

/*
* Return how long ticks are at the moment, that is, how much time
* update_wall_time_one_tick will add to xtime next time we call it
* (assuming no calls to do_adjtimex in the meantime).
* The return value is in fixed-point nanoseconds with SHIFT_SCALE-10
* bits to the right of the binary point.
* This function has no side-effects.
*/
u64 current_tick_length(void)
{
long delta_nsec;

delta_nsec = tick_nsec + adjtime_adjustment() * 1000;
return ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
}

/*
* Using a loop looks inefficient, but "ticks" is
* usually just one (we shouldn't be losing ticks,
Expand Down

0 comments on commit 0a318bd

Please sign in to comment.