Changes in libcfa/src/concurrency/invoke.h [63364d8:76e069f]
- File:
-
- 1 edited
-
libcfa/src/concurrency/invoke.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r63364d8 r76e069f 50 50 51 51 extern thread_local struct KernelThreadData { 52 struct coroutine_desc * volatile this_coroutine; 52 53 struct thread_desc * volatile this_thread; 53 54 struct processor * volatile this_processor; … … 60 61 } kernelTLS __attribute__ ((tls_model ( "initial-exec" ))); 61 62 } 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 ); } // UNSAFE 62 67 #endif 63 68 64 struct __stack_context_t { 65 void * SP; 66 void * FP; 67 }; 68 69 // low adresses : +----------------------+ <- start of allocation 70 // | optional guard page | 71 // +----------------------+ <- __stack_t.limit 72 // | | 73 // | /\ /\ /\ | 74 // | || || || | 75 // | | 76 // | program stack | 77 // | | 78 // __stack_info_t.storage -> +----------------------+ <- __stack_t.base 79 // | __stack_t | 80 // high adresses : +----------------------+ <- end of allocation 81 82 struct __stack_t { 83 // stack grows towards stack limit 84 void * limit; 85 86 // base of stack 87 void * base; 88 }; 89 90 struct __stack_info_t { 91 // pointer to stack 92 struct __stack_t * storage; 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 93 77 }; 94 78 … … 96 80 97 81 struct coroutine_desc { 98 // context that is switch during a CtxSwitch99 struct __stack_context_t context;100 101 82 // stack information of the coroutine 102 struct __stack_info_t stack;103 104 // textual name for coroutine/task 83 struct coStack_t stack; 84 85 // textual name for coroutine/task, initialized by uC++ generated code 105 86 const char * name; 87 88 // copy of global UNIX variable errno 89 int errno_; 106 90 107 91 // current execution status for coroutine 108 92 enum coroutine_state state; 109 110 93 // first coroutine to resume this one 111 94 struct coroutine_desc * starter; … … 161 144 struct thread_desc { 162 145 // Core threading fields 163 // context that is switch during a CtxSwitch164 struct __stack_context_t context;165 166 // current execution status for coroutine167 enum coroutine_state state;168 169 //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it170 171 146 // coroutine body used to store context 172 147 struct coroutine_desc self_cor; … … 195 170 struct thread_desc * prev; 196 171 } node; 197 }; 198 199 #ifdef __cforall 200 extern "Cforall" { 201 static inline struct coroutine_desc * active_coroutine() { return TL_GET( this_thread )->curr_cor; } 202 static inline struct thread_desc * active_thread () { return TL_GET( this_thread ); } 203 static inline struct processor * active_processor() { return TL_GET( this_processor ); } // UNSAFE 204 172 }; 173 174 #ifdef __cforall 175 extern "Cforall" { 205 176 static inline thread_desc * & get_next( thread_desc & this ) { 206 177 return this.next; … … 260 231 // assembler routines that performs the context switch 261 232 extern void CtxInvokeStub( void ); 262 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 263 // void CtxStore ( void * this ) asm ("CtxStore"); 264 // void CtxRet ( void * dst ) asm ("CtxRet"); 233 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch"); 234 235 #if defined( __i386 ) 236 #define CtxGet( ctx ) __asm__ ( \ 237 "movl %%esp,%0\n" \ 238 "movl %%ebp,%1\n" \ 239 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 240 #elif defined( __x86_64 ) 241 #define CtxGet( ctx ) __asm__ ( \ 242 "movq %%rsp,%0\n" \ 243 "movq %%rbp,%1\n" \ 244 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 245 #elif defined( __ARM_ARCH ) 246 #define CtxGet( ctx ) __asm__ ( \ 247 "mov %0,%%sp\n" \ 248 "mov %1,%%r11\n" \ 249 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 250 #else 251 #error unknown hardware architecture 252 #endif 265 253 266 254 #endif //_INVOKE_PRIVATE_H_
Note:
See TracChangeset
for help on using the changeset viewer.