Changeset f787c8e in mainline for uspace/lib/c/generic
- Timestamp:
- 2018-08-01T18:37:54Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 82d9087
- Parents:
- 1de92fb0
- Location:
- uspace/lib/c/generic
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/ports.c
r1de92fb0 rf787c8e 51 51 #include <abi/mm/as.h> 52 52 #include "../private/libc.h" 53 #include "../private/fibril.h" 53 54 54 55 /** Interface data */ -
uspace/lib/c/generic/io/kio.c
r1de92fb0 rf787c8e 44 44 #include <macros.h> 45 45 #include <libarch/config.h> 46 #include <futex.h> 46 47 #include "../private/futex.h" 47 48 48 49 #define KIO_BUFFER_SIZE PAGE_SIZE -
uspace/lib/c/generic/ipc.c
r1de92fb0 rf787c8e 46 46 #include <errno.h> 47 47 #include <adt/list.h> 48 #include <futex.h>49 48 #include <fibril.h> 50 49 #include <macros.h> -
uspace/lib/c/generic/malloc.c
r1de92fb0 rf787c8e 44 44 #include <bitops.h> 45 45 #include <mem.h> 46 #include <fibril_synch.h>47 46 #include <stdlib.h> 48 47 #include <adt/gcdlcm.h> 48 49 49 #include "private/malloc.h" 50 #include "private/fibril.h" 50 51 51 52 /** Magic used in heap headers. */ -
uspace/lib/c/generic/private/fibril.h
r1de92fb0 rf787c8e 35 35 #include <abi/proc/uarg.h> 36 36 #include <atomic.h> 37 #include <futex.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}) 38 46 39 47 struct fibril { … … 73 81 extern void __fibrils_init(void); 74 82 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 its 94 * use. Within a rmutex critical section, you 95 * - may not use any other synchronization primitive, 96 * save for another `fibril_rmutex_t`. This includes nonblocking 97 * operations like cvar signal and mutex unlock, unless otherwise 98 * specified. 99 * - may not read IPC messages 100 * - may not start a new thread/fibril 101 * (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 current 109 // futex use behind a fibril based abstraction. Later, the imple- 110 // mentation will change, but the restrictions placed on this type 111 // 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 are 115 // running on a single thread, no other fibril can ever get to run 116 // while a fibril has a rmutex locked. That means that for 117 // single-threaded programs, we can reduce all rmutex locks and 118 // 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 75 135 #endif -
uspace/lib/c/generic/thread/fibril.c
r1de92fb0 rf787c8e 42 42 #include <as.h> 43 43 #include <context.h> 44 #include <futex.h>45 44 #include <assert.h> 46 45 … … 51 50 52 51 #include "../private/thread.h" 52 #include "../private/futex.h" 53 53 #include "../private/fibril.h" 54 54 #include "../private/libc.h" -
uspace/lib/c/generic/thread/fibril_synch.c
r1de92fb0 rf787c8e 37 37 #include <async.h> 38 38 #include <adt/list.h> 39 #include <futex.h>40 39 #include <sys/time.h> 41 40 #include <errno.h> … … 50 49 #include "../private/async.h" 51 50 #include "../private/fibril.h" 51 #include "../private/futex.h" 52 52 53 53 void fibril_rmutex_initialize(fibril_rmutex_t *m) -
uspace/lib/c/generic/thread/futex.c
r1de92fb0 rf787c8e 33 33 */ 34 34 35 #include <futex.h>36 37 35 #include <assert.h> 38 36 #include <atomic.h> … … 41 39 42 40 #include "../private/fibril.h" 41 #include "../private/futex.h" 43 42 44 43 //#define DPRINTF(...) kio_printf(__VA_ARGS__) -
uspace/lib/c/generic/thread/mpsc.c
r1de92fb0 rf787c8e 36 36 #include <mem.h> 37 37 #include <stdlib.h> 38 39 #include "../private/fibril.h" 38 40 39 41 /* -
uspace/lib/c/generic/thread/rcu.c
r1de92fb0 rf787c8e 73 73 #include <compiler/barrier.h> 74 74 #include <libarch/barrier.h> 75 #include <futex.h>76 75 #include <macros.h> 77 76 #include <async.h>
Note:
See TracChangeset
for help on using the changeset viewer.