Changeset 04e6f93 for libcfa/src/concurrency/invoke.h
- Timestamp:
- Feb 27, 2020, 4:04:25 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a037f85
- Parents:
- 41efd33 (diff), 930b504 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r41efd33 r04e6f93 47 47 extern "Cforall" { 48 48 extern __attribute__((aligned(128))) thread_local struct KernelThreadData { 49 struct thread_desc* volatile this_thread;49 struct $thread * volatile this_thread; 50 50 struct processor * volatile this_processor; 51 51 … … 92 92 }; 93 93 94 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 95 96 struct coroutine_desc { 97 // 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 98 99 struct __stack_context_t context; 99 100 … … 108 109 109 110 // first coroutine to resume this one 110 struct coroutine_desc* starter;111 struct $coroutine * starter; 111 112 112 113 // last coroutine to resume this one 113 struct coroutine_desc* last;114 struct $coroutine * last; 114 115 115 116 // If non-null stack must be unwound with this exception … … 127 128 }; 128 129 129 struct monitor_desc{130 struct $monitor { 130 131 // spinlock to protect internal data 131 132 struct __spinlock_t lock; 132 133 133 134 // current owner of the monitor 134 struct thread_desc* owner;135 struct $thread * owner; 135 136 136 137 // queue of threads that are blocked waiting for the monitor 137 __queue_t(struct thread_desc) entry_queue;138 __queue_t(struct $thread) entry_queue; 138 139 139 140 // stack of conditions to run next once we exit the monitor … … 152 153 struct __monitor_group_t { 153 154 // currently held monitors 154 __cfa_anonymous_object( __small_array_t( monitor_desc*) );155 __cfa_anonymous_object( __small_array_t($monitor*) ); 155 156 156 157 // last function that acquired monitors … … 158 159 }; 159 160 160 struct thread_desc{161 struct $thread { 161 162 // Core threading fields 162 // context that is switch during a CtxSwitch163 // context that is switch during a __cfactx_switch 163 164 struct __stack_context_t context; 164 165 165 166 // current execution status for coroutine 166 enum coroutine_state state; 167 volatile int state; 168 enum __Preemption_Reason preempted; 167 169 168 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 169 171 170 172 // coroutine body used to store context 171 struct coroutine_descself_cor;173 struct $coroutine self_cor; 172 174 173 175 // current active context 174 struct coroutine_desc* curr_cor;176 struct $coroutine * curr_cor; 175 177 176 178 // monitor body used for mutual exclusion 177 struct monitor_descself_mon;179 struct $monitor self_mon; 178 180 179 181 // pointer to monitor with sufficient lifetime for current monitors 180 struct monitor_desc* self_mon_p;182 struct $monitor * self_mon_p; 181 183 182 184 // pointer to the cluster on which the thread is running … … 188 190 // Link lists fields 189 191 // instrusive link field for threads 190 struct thread_desc* next;192 struct $thread * next; 191 193 192 194 struct { 193 struct thread_desc* next;194 struct thread_desc* prev;195 struct $thread * next; 196 struct $thread * prev; 195 197 } node; 196 198 }; … … 198 200 #ifdef __cforall 199 201 extern "Cforall" { 200 static inline thread_desc *& get_next( thread_desc & this) {202 static inline $thread *& get_next( $thread & this ) __attribute__((const)) { 201 203 return this.next; 202 204 } 203 205 204 static inline [ thread_desc *&, thread_desc *& ] __get( thread_desc & this) {206 static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) { 205 207 return this.node.[next, prev]; 206 208 } … … 212 214 } 213 215 214 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) { 215 217 (this.data){data}; 216 218 (this.size){size}; … … 218 220 } 219 221 220 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)) { 221 223 if( (lhs.data != 0) != (rhs.data != 0) ) return false; 222 224 if( lhs.size != rhs.size ) return false; … … 252 254 253 255 // assembler routines that performs the context switch 254 extern void CtxInvokeStub( void );255 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"); 256 258 // void CtxStore ( void * this ) asm ("CtxStore"); 257 259 // void CtxRet ( void * dst ) asm ("CtxRet");
Note:
See TracChangeset
for help on using the changeset viewer.