aboutsummaryrefslogtreecommitdiff
path: root/docs/devel/clocks.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/devel/clocks.rst')
-rw-r--r--docs/devel/clocks.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst
index f0391e7..956bd14 100644
--- a/docs/devel/clocks.rst
+++ b/docs/devel/clocks.rst
@@ -360,6 +360,18 @@ rather than simply passing it to a QEMUTimer function like
``timer_mod_ns()`` then you should be careful to avoid overflow
in those calculations, of course.)
+Obtaining tick counts
+---------------------
+
+For calculations where you need to know the number of ticks in
+a given duration, use ``clock_ns_to_ticks()``. This function handles
+possible non-whole-number-of-nanoseconds periods and avoids
+potential rounding errors. It will return '0' if the clock is stopped
+(i.e. it has period zero). If the inputs imply a tick count that
+overflows a 64-bit value (a very long duration for a clock with a
+very short period) the output value is truncated, so effectively
+the 64-bit output wraps around.
+
Changing a clock period
-----------------------