Add the notify UST application scheme
[lttng-tools.git] / ltt-sessiond / futex.c
index 0c333fce68e5fef0d2d881ef2b19435ccea6c48b..de3f94e6e6a0bb6dcbc25505721ad033c398a1c1 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #define _GNU_SOURCE
+#include <limits.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <urcu.h>
  * Ref: git://git.lttng.org/userspace-rcu.git
  */
 
+/*
+ * Update futex according to active or not. This scheme is used to wake every
+ * libust waiting on the shared memory map futex hence the INT_MAX used in the
+ * futex() call. If active, we set the value and wake everyone else we indicate
+ * that we are gone (cleanup() case).
+ */
+void futex_wait_update(int32_t *futex, int active)
+{
+       if (active) {
+               uatomic_set(futex, 1);
+               futex_async(futex, FUTEX_WAKE,
+                               INT_MAX, NULL, NULL, 0);
+       } else {
+               uatomic_set(futex, 0);
+       }
+
+       DBG("Futex wait update active %d", active);
+}
+
 /*
  * Prepare futex.
  */
This page took 0.02313 seconds and 4 git commands to generate.