NetBSD-Bugs archive

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

kern/43997: Kernel timer discrepancies

>Number:         43997
>Category:       kern
>Synopsis:       Kernel timer discrepancies
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 24 13:05:00 +0000 2010
>Originator:     Paul Goyette
>Release:        NetBSD 5.99.39
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at |
| Kernel Developer |                          | pgoyette at  |
System: NetBSD 5.99.39 NetBSD 5.99.39 (WHOOPPEE 2010-09-12 
22:12:41) #0: Thu Sep 30 21:01:33 PDT 2010
Architecture: x86_64
Machine: amd64
The routines sleep(3), usleep(3), and nanosleep(2) wake-up based on the 
occurrence of clock ticks.  However, the timer interrupt routine determines
the actual absolute time.  Normally this isn't an issue, but on systems 
that can "miss" interrupts it can result in significant discrepancies.

One such system is qemu, frequently used for providing a system test-bed
environment.  On (at least) amd64 architecture, qemu cannot simulate clock
interrupts at 100Hz.  Therefore, a simple "date ; sleep 5; date" command
actually requires 10 seconds to complete!

This problem was first noticed while debugging atf tests for the swwdog(4)
driver.  The test program used sleep() to schedule tickling of the wdog,
while the kernel uses a callout() with an absolute time to expire the
wdog timer.  The test program attempted to wait to the middle of the timer
interval, but due to this time discrepancy the wait time was doubled and
the timer expired before the wdog could be tickled.
See above.


Home | Main Index | Thread Index | Old Index