Changes in uspace/lib/c/generic/private/fibril.h [f787c8e:2965d18] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/private/fibril.h
rf787c8e r2965d18 35 35 #include <abi/proc/uarg.h> 36 36 #include <atomic.h> 37 #include <fibril.h> 38 39 #include "./futex.h" 40 41 typedef struct { 42 fibril_t *fibril; 43 } fibril_event_t; 44 45 #define FIBRIL_EVENT_INIT ((fibril_event_t) {0}) 37 #include <futex.h> 46 38 47 39 struct fibril { … … 81 73 extern void __fibrils_init(void); 82 74 83 extern void fibril_wait_for(fibril_event_t *);84 extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timeval *);85 extern void fibril_notify(fibril_event_t *);86 87 extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timeval *);88 extern void fibril_ipc_poke(void);89 90 /**91 * "Restricted" fibril mutex.92 *93 * Similar to `fibril_mutex_t`, but has a set of restrictions placed on its94 * use. Within a rmutex critical section, you95 * - may not use any other synchronization primitive,96 * save for another `fibril_rmutex_t`. This includes nonblocking97 * operations like cvar signal and mutex unlock, unless otherwise98 * specified.99 * - may not read IPC messages100 * - may not start a new thread/fibril101 * (creating fibril without starting is fine)102 *103 * Additionally, locking with a timeout is not possible on this mutex,104 * and there is no associated condition variable type.105 * This is a design constraint, not a lack of implementation effort.106 */107 typedef struct {108 // TODO: At this point, this is just silly handwaving to hide current109 // futex use behind a fibril based abstraction. Later, the imple-110 // mentation will change, but the restrictions placed on this type111 // will allow it to be simpler and faster than a regular mutex.112 // There might also be optional debug checking of the assumptions.113 //114 // Note that a consequence of the restrictions is that if we are115 // running on a single thread, no other fibril can ever get to run116 // while a fibril has a rmutex locked. That means that for117 // single-threaded programs, we can reduce all rmutex locks and118 // unlocks to simple branches on a global bool variable.119 120 futex_t futex;121 } fibril_rmutex_t;122 123 #define FIBRIL_RMUTEX_INITIALIZER(name) \124 { .futex = FUTEX_INITIALIZE(1) }125 126 #define FIBRIL_RMUTEX_INITIALIZE(name) \127 fibril_rmutex_t name = FIBRIL_RMUTEX_INITIALIZER(name)128 129 extern void fibril_rmutex_initialize(fibril_rmutex_t *);130 extern void fibril_rmutex_lock(fibril_rmutex_t *);131 extern bool fibril_rmutex_trylock(fibril_rmutex_t *);132 extern void fibril_rmutex_unlock(fibril_rmutex_t *);133 134 135 75 #endif
Note:
See TracChangeset
for help on using the changeset viewer.