Changeset 8f49a54 for src/libcfa
- Timestamp:
- Jan 19, 2017, 3:42:29 PM (8 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:
- dcb42b8
- Parents:
- 4a3386b4
- Location:
- src/libcfa/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutines.c
r4a3386b4 r8f49a54 100 100 // is not inline (We can't inline Cforall in C) 101 101 void suspend_no_inline(void) { 102 LIB_DEBUG_PRINTF("Suspending back : to %p from %p\n", this_coroutine(), this_coroutine() ? this_coroutine()->last : (void*)-1);103 104 102 suspend(); 105 103 } -
src/libcfa/concurrency/invoke.c
r4a3386b4 r8f49a54 33 33 main( this ); 34 34 35 cor->state = Halt; 36 cor->notHalted = false; 37 35 38 //Final suspend, should never return 36 39 __suspend_no_inline__F___1(); … … 54 57 main( this ); 55 58 59 cor->state = Halt; 60 cor->notHalted = false; 56 61 __scheduler_remove__F_P9sthread_h__1(thrd); 57 62 -
src/libcfa/concurrency/kernel.c
r4a3386b4 r8f49a54 119 119 // context switch to specified coroutine 120 120 // Which is now the current_coroutine 121 LIB_DEBUG_PRINTF("Kernel : switching to ctx %p (from %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);121 // LIB_DEBUG_PRINTF("Kernel : switching to ctx %p (from %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine); 122 122 current_coroutine = thrd_ctx; 123 123 CtxSwitch( proc_ctx->stack.context, thrd_ctx->stack.context ); 124 124 current_coroutine = proc_ctx; 125 LIB_DEBUG_PRINTF("Kernel : returned from ctx %p (to %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);125 // LIB_DEBUG_PRINTF("Kernel : returned from ctx %p (to %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine); 126 126 127 127 // when CtxSwitch returns we are back in the processor coroutine … … 136 136 137 137 void scheduler_add( thread_h * thrd ) { 138 LIB_DEBUG_PRINTF("Kernel : scheduling %p on core %p (%d spots)\n", thrd, systemProcessor, systemProcessor->thread_count);139 138 for(int i = 0; i < systemProcessor->thread_count; i++) { 140 139 if(systemProcessor->threads[i] == NULL) { … … 143 142 } 144 143 } 145 assert (false);144 assertf(false, "Scheduler full"); 146 145 } 147 146 148 147 void scheduler_remove( thread_h * thrd ) { 149 LIB_DEBUG_PRINTF("Kernel : unscheduling %p from core %p\n", thrd, systemProcessor);150 148 for(int i = 0; i < systemProcessor->thread_count; i++) { 151 149 if(systemProcessor->threads[i] == thrd) { 152 150 systemProcessor->threads[i] = NULL; 153 break;154 }155 }156 for(int i = 0; i < systemProcessor->thread_count; i++) {157 if(systemProcessor->threads[i] != NULL) {158 151 return; 159 152 } 160 153 } 161 LIB_DEBUG_PRINTF("Kernel : terminating core %p\n", systemProcessor); 162 systemProcessor->terminated = true; 154 assertf(false, "Trying to unschedule unkown thread"); 163 155 } 164 156 … … 229 221 230 222 mainThread_info_t ctx; 231 LIB_DEBUG_PRINTF("Kernel : base : %p\n", ctx.base );232 LIB_DEBUG_PRINTF("Kernel : top : %p\n", ctx.top );233 LIB_DEBUG_PRINTF("Kernel : limit : %p\n", ctx.limit );234 LIB_DEBUG_PRINTF("Kernel : size : %x\n", ctx.size );235 LIB_DEBUG_PRINTF("Kernel : storage : %p\n", ctx.storage );236 LIB_DEBUG_PRINTF("Kernel : context : %p\n", ctx.context );223 // LIB_DEBUG_PRINTF("Kernel : base : %p\n", ctx.base ); 224 // LIB_DEBUG_PRINTF("Kernel : top : %p\n", ctx.top ); 225 // LIB_DEBUG_PRINTF("Kernel : limit : %p\n", ctx.limit ); 226 // LIB_DEBUG_PRINTF("Kernel : size : %x\n", ctx.size ); 227 // LIB_DEBUG_PRINTF("Kernel : storage : %p\n", ctx.storage ); 228 // LIB_DEBUG_PRINTF("Kernel : context : %p\n", ctx.context ); 237 229 238 230 // Start by initializing the main thread … … 265 257 scheduler_remove(mainThread); 266 258 267 LIB_DEBUG_PRINTF("Suspending main\n"); 259 LIB_DEBUG_PRINTF("Kernel : Terminating system processor\n"); 260 systemProcessor->terminated = true; 261 268 262 suspend(); 269 263 270 LIB_DEBUG_PRINTF("Kernel : Control return to initial process thread\n");264 LIB_DEBUG_PRINTF("Kernel : Control returned to initial process thread\n"); 271 265 272 266 ^(systemProcessor->ctx){}; -
src/libcfa/concurrency/threads
r4a3386b4 r8f49a54 33 33 void ^?{}(T*);*/ 34 34 }; 35 36 #define DECL_THREAD(X) static inline thread_h* get_thread(X* this) { return &this->t; } void main(X* this); 35 37 36 38 forall(otype T | is_thread(T) ) -
src/libcfa/concurrency/threads.c
r4a3386b4 r8f49a54 46 46 forall(otype T | is_thread(T) ) 47 47 void ?{}( thread(T)* this ) { 48 printf("thread() ctor\n");49 48 (&this->handle){}; 50 49 start(this); … … 89 88 forall(otype T | is_thread(T) ) 90 89 void stop( thread(T)* this ) { 91 90 T* handle = &this->handle; 91 thread_h* thrd_h = get_thread (handle); 92 while( thrd_h->c.notHalted ) { 93 suspend(); 94 } 92 95 } 93 96
Note: See TracChangeset
for help on using the changeset viewer.