- File:
-
- 1 edited
-
libcfa/src/concurrency/invoke.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r212c2187 r5b11c25 62 62 #endif 63 63 64 struct coStack_t { 65 size_t size; // size of stack 66 void * storage; // pointer to stack 67 void * limit; // stack grows towards stack limit 68 void * base; // base of stack 69 void * context; // address of cfa_context_t 70 void * top; // address of top of storage 71 bool userStack; // whether or not the user allocated the stack 72 }; 73 74 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 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; 93 }; 94 95 enum coroutine_state { Halted, Start, Inactive, Active, Primed, PreInactive }; 75 96 76 97 struct coroutine_desc { 98 // context that is switch during a CtxSwitch 99 struct __stack_context_t context; 100 77 101 // stack information of the coroutine 78 struct coStack_t stack;79 80 // textual name for coroutine/task , initialized by uC++ generated code102 struct __stack_info_t stack; 103 104 // textual name for coroutine/task 81 105 const char * name; 82 83 // copy of global UNIX variable errno84 int errno_;85 106 86 107 // current execution status for coroutine 87 108 enum coroutine_state state; 109 88 110 // first coroutine to resume this one 89 111 struct coroutine_desc * starter; … … 139 161 struct thread_desc { 140 162 // Core threading fields 163 // context that is switch during a CtxSwitch 164 struct __stack_context_t context; 165 166 // current execution status for coroutine 167 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 it 170 141 171 // coroutine body used to store context 142 172 struct coroutine_desc self_cor; … … 169 199 #ifdef __cforall 170 200 extern "Cforall" { 171 static inline struct coroutine_desc * volatileactive_coroutine() { return TL_GET( this_thread )->curr_cor; }172 static inline struct thread_desc * volatileactive_thread () { return TL_GET( this_thread ); }173 static inline struct processor * volatileactive_processor() { return TL_GET( this_processor ); } // UNSAFE201 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 174 204 175 205 static inline thread_desc * & get_next( thread_desc & this ) { … … 230 260 // assembler routines that performs the context switch 231 261 extern void CtxInvokeStub( void ); 232 void CtxSwitch( void * from, void* to ) asm ("CtxSwitch");262 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 233 263 // void CtxStore ( void * this ) asm ("CtxStore"); 234 264 // void CtxRet ( void * dst ) asm ("CtxRet"); 235 236 #if defined( __i386 )237 #define CtxGet( ctx ) __asm__ ( \238 "movl %%esp,%0\n" \239 "movl %%ebp,%1\n" \240 : "=rm" (ctx.SP), "=rm" (ctx.FP) )241 #elif defined( __x86_64 )242 #define CtxGet( ctx ) __asm__ ( \243 "movq %%rsp,%0\n" \244 "movq %%rbp,%1\n" \245 : "=rm" (ctx.SP), "=rm" (ctx.FP) )246 #elif defined( __ARM_ARCH )247 #define CtxGet( ctx ) __asm__ ( \248 "mov %0,%%sp\n" \249 "mov %1,%%r11\n" \250 : "=rm" (ctx.SP), "=rm" (ctx.FP) )251 #else252 #error unknown hardware architecture253 #endif254 265 255 266 #endif //_INVOKE_PRIVATE_H_
Note:
See TracChangeset
for help on using the changeset viewer.