Changeset 7a560c1 for src/libcfa/concurrency
- Timestamp:
- Feb 2, 2017, 4:06:26 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6215a5c, 7d6639d
- Parents:
- fa2de95 (diff), 99b75cab (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. - Location:
- src/libcfa/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/CtxSwitch-x86_64.S
rfa2de95 r7a560c1 49 49 // Save volatile registers on the stack. 50 50 51 subq $8,%rsp 52 stmxcsr 0(%rsp) // 4 bytes 53 fnstcw 4(%rsp) // 2 bytes 51 54 pushq %r15 52 55 pushq %r14 … … 72 75 popq %r14 73 76 popq %r15 77 fldcw 4(%rsp) 78 ldmxcsr 0(%rsp) 79 addq $8,%rsp 74 80 75 81 // Return to thread. -
src/libcfa/concurrency/coroutines
rfa2de95 r7a560c1 30 30 }; 31 31 32 #define DECL_COROUTINE(X) static inline coroutine* get_coroutine(X* this) { return &this->c; } void main(X* this) ;32 #define DECL_COROUTINE(X) static inline coroutine* get_coroutine(X* this) { return &this->c; } void main(X* this) 33 33 34 34 //----------------------------------------------------------------------------- … … 110 110 } 111 111 112 static inline void resume(coroutine * dst) { 113 coroutine * src = this_coroutine(); // optimization 114 115 // not resuming self ? 116 if ( src != dst ) { 117 assertf( dst->notHalted , 118 "Attempt by coroutine %.256s (%p) to resume terminated coroutine %.256s (%p).\n" 119 "Possible cause is terminated coroutine's main routine has already returned.", 120 src->name, src, dst->name, dst ); 121 122 // set last resumer 123 dst->last = src; 124 } // if 125 126 // always done for performance testing 127 CoroutineCtxSwitch( src, dst ); 128 } 129 112 130 #endif //COROUTINES_H 113 131 -
src/libcfa/concurrency/invoke.c
rfa2de95 r7a560c1 109 109 struct FakeStack { 110 110 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15 111 void *rturn; // where to go on return from uSwitch 111 uint32_t mxcr; // SSE Status and Control bits (control bits are preserved across function calls) 112 uint16_t fcw; // X97 FPU control word (preserved across function calls) 113 void *rturn; // where to go on return from uSwitch 112 114 void *dummyReturn; // NULL return address to provide proper alignment 113 115 }; … … 120 122 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this; 121 123 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke; 124 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520 125 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F; //Vol. 1 8-7 122 126 #else 123 127 #error Only __i386__ and __x86_64__ is supported for threads in cfa -
src/libcfa/concurrency/kernel.c
rfa2de95 r7a560c1 43 43 }; 44 44 45 DECL_COROUTINE(processorCtx_t) 45 DECL_COROUTINE(processorCtx_t); 46 46 47 47 #define KERNEL_STORAGE(T,X) static char X##_storage[sizeof(T)] -
src/libcfa/concurrency/threads
rfa2de95 r7a560c1 32 32 }; 33 33 34 #define DECL_THREAD(X) thread* get_thread(X* this) { return &this->t; } void main(X* this) ;34 #define DECL_THREAD(X) thread* get_thread(X* this) { return &this->t; } void main(X* this) 35 35 36 36 forall( dtype T | is_thread(T) )
Note:
See TracChangeset
for help on using the changeset viewer.