Changes in libcfa/src/concurrency/invoke.h [3623f9d:ac2b598]
- File:
-
- 1 edited
-
libcfa/src/concurrency/invoke.h (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r3623f9d rac2b598 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 22 18:19:13 201913 // Update Count : 4 012 // Last Modified On : Thu Dec 5 16:26:03 2019 13 // Update Count : 44 14 14 // 15 15 … … 46 46 #ifdef __cforall 47 47 extern "Cforall" { 48 extern thread_local struct KernelThreadData {49 struct thread_desc* volatile this_thread;48 extern __attribute__((aligned(128))) thread_local struct KernelThreadData { 49 struct $thread * volatile this_thread; 50 50 struct processor * volatile this_processor; 51 51 … … 55 55 volatile bool in_progress; 56 56 } preemption_state; 57 58 uint32_t rand_seed; 57 59 } kernelTLS __attribute__ ((tls_model ( "initial-exec" ))); 58 60 } … … 90 92 }; 91 93 92 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 93 94 struct coroutine_desc { 95 // context that is switch during a CtxSwitch 94 enum coroutine_state { Halted, Start, Primed, Inactive, Active, Rerun }; 95 enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION }; 96 97 struct $coroutine { 98 // context that is switch during a __cfactx_switch 96 99 struct __stack_context_t context; 97 100 … … 106 109 107 110 // first coroutine to resume this one 108 struct coroutine_desc* starter;111 struct $coroutine * starter; 109 112 110 113 // last coroutine to resume this one 111 struct coroutine_desc* last;114 struct $coroutine * last; 112 115 113 116 // If non-null stack must be unwound with this exception … … 125 128 }; 126 129 127 struct monitor_desc{130 struct $monitor { 128 131 // spinlock to protect internal data 129 132 struct __spinlock_t lock; 130 133 131 134 // current owner of the monitor 132 struct thread_desc* owner;135 struct $thread * owner; 133 136 134 137 // queue of threads that are blocked waiting for the monitor 135 __queue_t(struct thread_desc) entry_queue;138 __queue_t(struct $thread) entry_queue; 136 139 137 140 // stack of conditions to run next once we exit the monitor … … 150 153 struct __monitor_group_t { 151 154 // currently held monitors 152 __cfa_anonymous_object( __small_array_t( monitor_desc*) );155 __cfa_anonymous_object( __small_array_t($monitor*) ); 153 156 154 157 // last function that acquired monitors … … 156 159 }; 157 160 158 struct thread_desc{161 struct $thread { 159 162 // Core threading fields 160 // context that is switch during a CtxSwitch163 // context that is switch during a __cfactx_switch 161 164 struct __stack_context_t context; 162 165 163 166 // current execution status for coroutine 164 enum coroutine_state state; 167 volatile int state; 168 enum __Preemption_Reason preempted; 165 169 166 170 //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it 167 171 168 172 // coroutine body used to store context 169 struct coroutine_descself_cor;173 struct $coroutine self_cor; 170 174 171 175 // current active context 172 struct coroutine_desc* curr_cor;176 struct $coroutine * curr_cor; 173 177 174 178 // monitor body used for mutual exclusion 175 struct monitor_descself_mon;179 struct $monitor self_mon; 176 180 177 181 // pointer to monitor with sufficient lifetime for current monitors 178 struct monitor_desc* self_mon_p;182 struct $monitor * self_mon_p; 179 183 180 184 // pointer to the cluster on which the thread is running … … 186 190 // Link lists fields 187 191 // instrusive link field for threads 188 struct thread_desc* next;192 struct $thread * next; 189 193 190 194 struct { 191 struct thread_desc* next;192 struct thread_desc* prev;195 struct $thread * next; 196 struct $thread * prev; 193 197 } node; 194 198 }; … … 196 200 #ifdef __cforall 197 201 extern "Cforall" { 198 static inline thread_desc *& get_next( thread_desc & this) {202 static inline $thread *& get_next( $thread & this ) __attribute__((const)) { 199 203 return this.next; 200 204 } 201 205 202 static inline [ thread_desc *&, thread_desc *& ] __get( thread_desc & this) {206 static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) { 203 207 return this.node.[next, prev]; 204 208 } 205 209 206 210 static inline void ?{}(__monitor_group_t & this) { 207 (this.data){ NULL};211 (this.data){0p}; 208 212 (this.size){0}; 209 213 (this.func){NULL}; 210 214 } 211 215 212 static inline void ?{}(__monitor_group_t & this, struct monitor_desc** data, __lock_size_t size, fptr_t func) {216 static inline void ?{}(__monitor_group_t & this, struct $monitor ** data, __lock_size_t size, fptr_t func) { 213 217 (this.data){data}; 214 218 (this.size){size}; … … 216 220 } 217 221 218 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {222 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) __attribute__((const)) { 219 223 if( (lhs.data != 0) != (rhs.data != 0) ) return false; 220 224 if( lhs.size != rhs.size ) return false; … … 250 254 251 255 // assembler routines that performs the context switch 252 extern void CtxInvokeStub( void );253 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch");256 extern void __cfactx_invoke_stub( void ); 257 extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch"); 254 258 // void CtxStore ( void * this ) asm ("CtxStore"); 255 259 // void CtxRet ( void * dst ) asm ("CtxRet");
Note:
See TracChangeset
for help on using the changeset viewer.