1 /* Copyright (c) 2013 The Regents of the University of California
2 * Barret Rhoden <brho@cs.berkeley.edu>
3 * See LICENSE for details.
5 * Plan9 style Rendezvous (http://plan9.bell-labs.com/sys/doc/sleep.html)
7 * We implement it with CVs, and it can handle multiple sleepers/wakers.
13 * rendez_sleep(&rv, some_func_taking_void*, void *arg);
15 * rendez_sleep_timeout(&rv, some_func_taking_void*, void *arg, msec);
17 * Waker usage: (can be used from IRQ context)
18 * // set the condition to TRUE, then:
22 * - Some_func checks some condition and returns TRUE when we want to wake up.
23 * - Sleep returns when the condition is true and when it has been woken up.
24 * It can return without sleeping or requiring a wakeup if the condition is
26 * - Wakers should set the condition, then trigger the wakeup to ensure the
27 * sleeper has awakened. (internal locks provide the needed barriers).
28 * - Timeout sleep is like regular sleep, with the addition that it will return
29 * after some milliseconds, regardless of the condition.
30 * - The only locking/protection is done internally. In plan9, they expect to
31 * only have one sleeper and one waker. So your code around the rendez needs
32 * to take that into account. The old plan9 code should already do this.
34 * - TODO: i dislike the int vs bool on the func pointer. prob would need to
35 * change all 9ns rendez functions
38 #ifndef ROS_KERN_RENDEZ_H
39 #define ROS_KERN_RENDEZ_H
41 #include <ros/common.h>
48 void rendez_init(struct rendez *rv);
49 void rendez_sleep(struct rendez *rv, int (*cond)(void*), void *arg);
50 void rendez_sleep_timeout(struct rendez *rv, int (*cond)(void*), void *arg,
52 bool rendez_wakeup(struct rendez *rv);
54 #endif /* ROS_KERN_RENDEZ_H */