Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga/dev Handle the situation of a wrapped interva...



details:   https://anonhg.NetBSD.org/src/rev/2806b0459234
branches:  trunk
changeset: 747337:2806b0459234
user:      phx <phx%NetBSD.org@localhost>
date:      Fri Sep 11 19:43:08 2009 +0000

description:
Handle the situation of a wrapped interval counter, while the hardclock()
interrupt was not yet executed to update the hardclock_ticks variable.

diffstat:

 sys/arch/amiga/dev/clock.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r c5154a4e5961 -r 2806b0459234 sys/arch/amiga/dev/clock.c
--- a/sys/arch/amiga/dev/clock.c        Fri Sep 11 19:22:15 2009 +0000
+++ b/sys/arch/amiga/dev/clock.c        Fri Sep 11 19:43:08 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.49 2009/09/11 13:11:15 phx Exp $ */
+/*     $NetBSD: clock.c,v 1.50 2009/09/11 19:43:08 phx Exp $ */
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49 2009/09/11 13:11:15 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.50 2009/09/11 19:43:08 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -326,6 +326,8 @@
 static u_int
 clk_getcounter(struct timecounter *tc)
 {
+       static int last_hardclock_ticks;
+       static u_int last_clock_tick = 0;
        int old_hardclock_ticks;
        u_int clock_tick;
 
@@ -334,6 +336,19 @@
                clock_tick = clk_gettick();
        } while (old_hardclock_ticks != hardclock_ticks);
 
+       /*
+        * Handle the situation of a wrapped interval counter, while
+        * the hardclock() interrupt was not yet executed to update
+        * hardclock_ticks.
+        */
+       if (last_hardclock_ticks > old_hardclock_ticks)
+               old_hardclock_ticks = last_hardclock_ticks;
+       if (clock_tick < last_clock_tick &&
+           old_hardclock_ticks == last_hardclock_ticks)
+               old_hardclock_ticks++;
+       last_hardclock_ticks = old_hardclock_ticks;
+       last_clock_tick = clock_tick;
+
        return old_hardclock_ticks * amiga_clk_interval + clock_tick;
 }
 



Home | Main Index | Thread Index | Old Index