Changeset b067d9b for libcfa/src/concurrency/invoke.h
- Timestamp:
- Oct 29, 2019, 4:01:24 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:
- 773db65, 9421f3d8
- Parents:
- 7951100 (diff), 8364209 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r7951100 rb067d9b 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 19 08:23:21 201813 // Update Count : 3114 // 15 16 #include "bits/containers.h "17 #include "bits/defs.h "18 #include "bits/locks.h "12 // Last Modified On : Sat Jun 22 18:19:13 2019 13 // Update Count : 40 14 // 15 16 #include "bits/containers.hfa" 17 #include "bits/defs.hfa" 18 #include "bits/locks.hfa" 19 19 20 20 #ifdef __cforall … … 46 46 #ifdef __cforall 47 47 extern "Cforall" { 48 static inline struct thread_desc * & get_next( struct thread_desc & this );49 static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );50 51 48 extern thread_local struct KernelThreadData { 52 struct coroutine_desc * volatile this_coroutine;53 49 struct thread_desc * volatile this_thread; 54 50 struct processor * volatile this_processor; … … 59 55 volatile bool in_progress; 60 56 } preemption_state; 61 } kernelTLS ;57 } kernelTLS __attribute__ ((tls_model ( "initial-exec" ))); 62 58 } 63 64 static inline struct coroutine_desc * volatile active_coroutine() { return TL_GET( this_coroutine ); }65 static inline struct thread_desc * volatile active_thread () { return TL_GET( this_thread ); }66 static inline struct processor * volatile active_processor() { return TL_GET( this_processor ); } // UNSAFE67 59 #endif 68 60 69 struct coStack_t { 70 size_t size; // size of stack 71 void * storage; // pointer to stack 72 void * limit; // stack grows towards stack limit 73 void * base; // base of stack 74 void * context; // address of cfa_context_t 75 void * top; // address of top of storage 76 bool userStack; // whether or not the user allocated the stack 61 struct __stack_context_t { 62 void * SP; 63 void * FP; 64 }; 65 66 // low adresses : +----------------------+ <- start of allocation 67 // | optional guard page | 68 // +----------------------+ <- __stack_t.limit 69 // | | 70 // | /\ /\ /\ | 71 // | || || || | 72 // | | 73 // | program stack | 74 // | | 75 // __stack_info_t.storage -> +----------------------+ <- __stack_t.base 76 // | __stack_t | 77 // high adresses : +----------------------+ <- end of allocation 78 79 struct __stack_t { 80 // stack grows towards stack limit 81 void * limit; 82 83 // base of stack 84 void * base; 85 }; 86 87 struct __stack_info_t { 88 // pointer to stack 89 struct __stack_t * storage; 77 90 }; 78 91 … … 80 93 81 94 struct coroutine_desc { 82 struct coStack_t stack; // stack information of the coroutine 83 const char * name; // textual name for coroutine/task, initialized by uC++ generated code 84 int errno_; // copy of global UNIX variable errno 85 enum coroutine_state state; // current execution status for coroutine 86 struct coroutine_desc * starter; // first coroutine to resume this one 87 struct coroutine_desc * last; // last coroutine to resume this one 88 }; 89 95 // context that is switch during a CtxSwitch 96 struct __stack_context_t context; 97 98 // stack information of the coroutine 99 struct __stack_info_t stack; 100 101 // textual name for coroutine/task 102 const char * name; 103 104 // current execution status for coroutine 105 enum coroutine_state state; 106 107 // first coroutine to resume this one 108 struct coroutine_desc * starter; 109 110 // last coroutine to resume this one 111 struct coroutine_desc * last; 112 113 // If non-null stack must be unwound with this exception 114 struct _Unwind_Exception * cancellation; 115 116 }; 117 118 // struct which calls the monitor is accepting 90 119 struct __waitfor_mask_t { 91 120 // the index of the accepted function, -1 if none … … 93 122 94 123 // list of acceptable functions, null if any 95 __ small_array_t(struct __acceptable_t) __cfa_anonymous_object;124 __cfa_anonymous_object( __small_array_t(struct __acceptable_t) ); 96 125 }; 97 126 … … 121 150 struct __monitor_group_t { 122 151 // currently held monitors 123 __ small_array_t(monitor_desc*) __cfa_anonymous_object;152 __cfa_anonymous_object( __small_array_t(monitor_desc*) ); 124 153 125 154 // last function that acquired monitors … … 129 158 struct thread_desc { 130 159 // Core threading fields 160 // context that is switch during a CtxSwitch 161 struct __stack_context_t context; 162 163 // current execution status for coroutine 164 enum coroutine_state state; 165 166 //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 131 168 // coroutine body used to store context 132 169 struct coroutine_desc self_cor; … … 155 192 struct thread_desc * prev; 156 193 } node; 157 158 159 160 161 static inline thread_desc * 194 }; 195 196 #ifdef __cforall 197 extern "Cforall" { 198 static inline thread_desc *& get_next( thread_desc & this ) { 162 199 return this.next; 163 200 } … … 166 203 return this.node.[next, prev]; 167 204 } 168 169 static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );170 205 171 206 static inline void ?{}(__monitor_group_t & this) { … … 216 251 // assembler routines that performs the context switch 217 252 extern void CtxInvokeStub( void ); 218 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch"); 219 220 #if defined( __i386 ) 221 #define CtxGet( ctx ) __asm__ ( \ 222 "movl %%esp,%0\n" \ 223 "movl %%ebp,%1\n" \ 224 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 225 #elif defined( __x86_64 ) 226 #define CtxGet( ctx ) __asm__ ( \ 227 "movq %%rsp,%0\n" \ 228 "movq %%rbp,%1\n" \ 229 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 230 #elif defined( __ARM_ARCH ) 231 #define CtxGet( ctx ) __asm__ ( \ 232 "mov %0,%%sp\n" \ 233 "mov %1,%%r11\n" \ 234 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 235 #else 236 #error unknown hardware architecture 237 #endif 253 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 254 // void CtxStore ( void * this ) asm ("CtxStore"); 255 // void CtxRet ( void * dst ) asm ("CtxRet"); 238 256 239 257 #endif //_INVOKE_PRIVATE_H_
Note:
See TracChangeset
for help on using the changeset viewer.