OpenBSD/src R9YNvBXsys/kern kern_tc.c

   Serialize tc_windup() calls and modification of some timehands members.

   If a user thread from e.g. clock_settime(2) is in the midst of changing
   the boottime or calling tc_windup() when it is interrupted by hardclock(9),
   the timehands could be left in a damaged state.

   So protect tc_windup() calls with a mutex, timecounter_mtx.  hardclock(9)
   merely attempts to enter the mutex instead of spinning because it cannot
   afford to wait around.  In practice hardclock(9) will skip tc_windup() very
   rarely, and when it does skip there aren't any negative effects because the
   skip indicates that a user thread is already calling, or about to call,
   tc_windup() anyway.

   Based on FreeBSD r303387 and NetBSD sys/kern/kern_tc.c,v1.30

   Discussed with mpi@ and visa@.  Tons of nice technical detail about
   lockless reads from visa@.

   OK visa@
VersionDeltaFile
1.36+20-4sys/kern/kern_tc.c
+20-41 files

UnifiedSplitRaw