summaryrefslogtreecommitdiff
path: root/kern/timer_i.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-08-31 23:17:47 +0200
committerRichard Braun <rbraun@sceen.net>2017-08-31 23:17:47 +0200
commitb9ec5cca6f6e3fd571b2e534d36e2498e488164c (patch)
treeeb3053068ba3451e41d655f883a9fcee8efff238 /kern/timer_i.h
parent4e0b9efa25b58f7fcaf485349f66bd694390080a (diff)
kern/timer: improve access synchronization
Diffstat (limited to 'kern/timer_i.h')
-rw-r--r--kern/timer_i.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/kern/timer_i.h b/kern/timer_i.h
index 4ed01f2..40e97f1 100644
--- a/kern/timer_i.h
+++ b/kern/timer_i.h
@@ -24,18 +24,32 @@
#include <kern/hlist.h>
#include <kern/work.h>
+/*
+ * Locking keys :
+ * (c) cpu_data
+ * (a) atomic
+ *
+ * (*) The ticks member represents the expiration date. It may be read without
+ * locking the timer, in which case it must be accessed atomically. It
+ * may only be updated when the timer is locked though, so reads at such
+ * times don't need to be atomic.
+ *
+ * (**) The cpu member is used to determine which lock serializes access to
+ * the structure. It must be accessed atomically, but updated while the
+ * timer is locked.
+ */
struct timer {
union {
- struct hlist_node node;
+ struct hlist_node node; /* (c) */
struct work work;
};
- uint64_t ticks;
+ uint64_t ticks; /* (c,a,*) */
timer_fn_t fn;
- unsigned int cpu;
- unsigned short state;
- unsigned short flags;
- struct thread *joiner;
+ unsigned int cpu; /* (c,a,**) */
+ unsigned short state; /* (c) */
+ unsigned short flags; /* (c) */
+ struct thread *joiner; /* (c) */
};
#endif /* _KERN_TIMER_I_H */