Changes in / [511aa69a:41a7137]
- Location:
- src
- Files:
-
- 2 deleted
- 8 edited
-
benchmark/CorCtxSwitch.c (deleted)
-
benchmark/ThrdCtxSwitch.c (deleted)
-
examples/Bench.c (modified) (4 diffs)
-
libcfa/concurrency/CtxSwitch-x86_64.S (modified) (2 diffs)
-
libcfa/concurrency/coroutines (modified) (2 diffs)
-
libcfa/concurrency/invoke.c (modified) (2 diffs)
-
libcfa/concurrency/kernel.c (modified) (1 diff)
-
libcfa/concurrency/threads (modified) (1 diff)
-
libcfa/containers/vector (modified) (2 diffs)
-
tests/thread.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/Bench.c
r511aa69a r41a7137 87 87 88 88 struct CoroutineDummy { coroutine c; }; 89 DECL_COROUTINE(CoroutineDummy) ;89 DECL_COROUTINE(CoroutineDummy) 90 90 void main(CoroutineDummy * this) {} 91 91 … … 122 122 }; 123 123 124 DECL_COROUTINE(CoroutineResume) ;124 DECL_COROUTINE(CoroutineResume) 125 125 126 126 void ?{}(CoroutineResume* this, int N) { … … 151 151 152 152 struct ThreadDummy { thread t; }; 153 DECL_THREAD(ThreadDummy) ;153 DECL_THREAD(ThreadDummy) 154 154 void main(ThreadDummy * this) {} 155 155 … … 183 183 }; 184 184 185 DECL_THREAD(ContextSwitch) ;185 DECL_THREAD(ContextSwitch) 186 186 187 187 void main(ContextSwitch * this) { -
src/libcfa/concurrency/CtxSwitch-x86_64.S
r511aa69a r41a7137 49 49 // Save volatile registers on the stack. 50 50 51 subq $8,%rsp52 stmxcsr 0(%rsp) // 4 bytes53 fnstcw 4(%rsp) // 2 bytes54 51 pushq %r15 55 52 pushq %r14 … … 75 72 popq %r14 76 73 popq %r15 77 fldcw 4(%rsp)78 ldmxcsr 0(%rsp)79 addq $8,%rsp80 74 81 75 // Return to thread. -
src/libcfa/concurrency/coroutines
r511aa69a r41a7137 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(); // optimization114 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 resumer123 dst->last = src;124 } // if125 126 // always done for performance testing127 CoroutineCtxSwitch( src, dst );128 }129 130 112 #endif //COROUTINES_H 131 113 -
src/libcfa/concurrency/invoke.c
r511aa69a r41a7137 109 109 struct FakeStack { 110 110 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15 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 111 void *rturn; // where to go on return from uSwitch 114 112 void *dummyReturn; // NULL return address to provide proper alignment 115 113 }; … … 122 120 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this; 123 121 ((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-520125 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F; //Vol. 1 8-7126 122 #else 127 123 #error Only __i386__ and __x86_64__ is supported for threads in cfa -
src/libcfa/concurrency/kernel.c
r511aa69a r41a7137 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
r511aa69a r41a7137 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) ) -
src/libcfa/containers/vector
r511aa69a r41a7137 118 118 } 119 119 120 //forall(otype T, otype allocator_t | allocator_c(T, allocator_t))121 //static inline const T* cbegin(const vector(T, allocator_t)* this)122 //{123 //return data(&this->storage);124 //}120 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 121 static inline const T* cbegin(const vector(T, allocator_t)* this) 122 { 123 return data(&this->storage); 124 } 125 125 126 126 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 130 130 } 131 131 132 //forall(otype T, otype allocator_t | allocator_c(T, allocator_t))133 //static inline const T* cend(const vector(T, allocator_t)* this)134 //{135 //return data(&this->storage) + this->size;136 //}132 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 133 static inline const T* cend(const vector(T, allocator_t)* this) 134 { 135 return data(&this->storage) + this->size; 136 } 137 137 138 138 //------------------------------------------------------------------------------ -
src/tests/thread.c
r511aa69a r41a7137 7 7 struct Second { thread t; simple_lock* lock; }; 8 8 9 DECL_THREAD(First) ;10 DECL_THREAD(Second) ;9 DECL_THREAD(First) 10 DECL_THREAD(Second) 11 11 12 12 void ?{}( First * this, simple_lock* lock ) { this->lock = lock; }
Note:
See TracChangeset
for help on using the changeset viewer.