diff options
author | Ian Lepore <ian@FreeBSD.org> | 2017-07-31 01:18:21 +0000 |
---|---|---|
committer | Ian Lepore <ian@FreeBSD.org> | 2017-07-31 01:18:21 +0000 |
commit | cd9d9e5417583b89e1d0a505182ebc33e4d1fad3 (patch) | |
tree | 677913015155f19ac1a9c052f1c80d714ea10f89 /sys/sys/clock.h | |
parent | d0f68f913b2768369f266c0ff4b13b09586fd56b (diff) | |
download | src-cd9d9e5417583b89e1d0a505182ebc33e4d1fad3.tar.gz src-cd9d9e5417583b89e1d0a505182ebc33e4d1fad3.zip |
Add clock_schedule(), a feature that allows realtime clock drivers to
request that their clock_settime() methods be called at a given offset
from top-of-second. This adds a timeout_task to the rtc_instance so that
each clock can be separately added to taskqueue_thread with the scheduling
it prefers, instead of looping through all the clocks at once with a
single task on taskqueue_thread. If a driver doesn't call clock_schedule()
the default is the old behavior: clock_settime() is queued immediately.
The motivation behind this is that I was on the path of adding identical
code to a third RTC driver to figure out a delta to top-of-second and
sleep for that amount of time because writing the the RTC registers resets
the hardware's concept of top-of-second. (Sometimes it's not top-of-second,
some RTC clocks tick over a half second after you set their time registers.)
Worst-case would be to sleep for almost a full second, which is a rude thing
to do on a shared task queue thread.
Notes
Notes:
svn path=/head/; revision=321745
Diffstat (limited to 'sys/sys/clock.h')
-rw-r--r-- | sys/sys/clock.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/sys/clock.h b/sys/sys/clock.h index 696ff55eee14..a5e625a81422 100644 --- a/sys/sys/clock.h +++ b/sys/sys/clock.h @@ -77,9 +77,16 @@ int clock_ct_to_ts(struct clocktime *, struct timespec *); void clock_ts_to_ct(struct timespec *, struct clocktime *); /* - * Time-of-day clock register/unregister functions, and associated flags. These - * functions can sleep. Upon return from unregister, the clock's methods are - * not running and will not be called again. + * Time-of-day clock functions and flags. These functions might sleep. + * + * clock_register and clock_unregister() do what they say. Upon return from + * unregister, the clock's methods are not running and will not be called again. + * + * clock_schedule() requests that a registered clock's clock_settime() calls + * happen at the given offset into the second. The default is 0, meaning no + * specific scheduling. To schedule the call as soon after top-of-second as + * possible, specify 1. Each clock has its own schedule, but taskqueue_thread + * is shared by many tasks; the timing of the call is not guaranteed. * * Flags: * @@ -102,6 +109,7 @@ void clock_ts_to_ct(struct timespec *, struct clocktime *); void clock_register(device_t _clockdev, long _resolution_us); void clock_register_flags(device_t _clockdev, long _resolution_us, int _flags); +void clock_schedule(device_t clockdev, u_int _offsetns); void clock_unregister(device_t _clockdev); /* |