Changes in / [520145b:d893266a]
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.h
r520145b rd893266a 72 72 } 73 73 74 75 76 74 77 // Local Variables: // 75 78 // tab-width: 4 // -
src/libcfa/concurrency/kernel
r520145b rd893266a 79 79 80 80 // Processor 81 coroutine processorCtx_t {82 struct processor * proc;83 };84 85 81 // Wrapper around kernel threads 86 82 struct processor { 87 83 // Main state 88 84 // Coroutine ctx who does keeps the state of the processor 89 struct processorCtx_t runner;85 struct processorCtx_t * runner; 90 86 91 87 // Cluster from which to get threads -
src/libcfa/concurrency/kernel.c
r520145b rd893266a 124 124 //----------------------------------------------------------------------------- 125 125 // Processor coroutine 126 void ?{}(processorCtx_t & this) {}127 126 128 127 // Construct the processor context of the main processor … … 131 130 this.__cor.starter = NULL; 132 131 this.proc = proc; 132 proc->runner = &this; 133 133 } 134 134 … … 137 137 (this.__cor){ info }; 138 138 this.proc = proc; 139 proc->runner = &this; 139 140 } 140 141 … … 149 150 preemption_alarm = NULL; 150 151 pending_preemption = false; 151 runner.proc = &this;152 152 153 153 start( &this ); … … 161 161 pending_preemption = false; 162 162 kernel_thread = pthread_self(); 163 runner.proc = &this; 164 163 164 this.runner = &runner; 165 165 __cfaabi_dbg_print_safe("Kernel : constructing main processor context %p\n", &runner); 166 166 runner{ &this }; … … 196 196 void main(processorCtx_t & runner) { 197 197 processor * this = runner.proc; 198 verify(this);199 198 200 199 __cfaabi_dbg_print_safe("Kernel : core %p starting\n", this); … … 242 241 void runThread(processor * this, thread_desc * dst) { 243 242 assert(dst->curr_cor); 244 coroutine_desc * proc_cor = get_coroutine( this->runner);243 coroutine_desc * proc_cor = get_coroutine(*this->runner); 245 244 coroutine_desc * thrd_cor = dst->curr_cor; 246 245 … … 257 256 258 257 void returnToKernel() { 259 coroutine_desc * proc_cor = get_coroutine( this_processor->runner);258 coroutine_desc * proc_cor = get_coroutine(*this_processor->runner); 260 259 coroutine_desc * thrd_cor = this_thread->curr_cor = this_coroutine; 261 260 ThreadCtxSwitch(thrd_cor, proc_cor); … … 318 317 machine_context_t ctx; 319 318 info.context = &ctx; 320 (proc->runner){ proc, &info };321 322 __cfaabi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.base);319 processorCtx_t proc_cor_storage = { proc, &info }; 320 321 __cfaabi_dbg_print_safe("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base); 323 322 324 323 //Set global state 325 this_coroutine = get_coroutine(proc->runner);324 this_coroutine = &proc->runner->__cor; 326 325 this_thread = NULL; 327 326 328 327 //We now have a proper context from which to schedule threads 329 __cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);328 __cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx); 330 329 331 330 // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't … … 333 332 // back to here. Instead directly call the main since we already are on the 334 333 // appropriate stack. 335 get_coroutine(proc->runner)->state = Active;336 main( proc ->runner);337 get_coroutine(proc->runner)->state = Halted;334 proc_cor_storage.__cor.state = Active; 335 main( proc_cor_storage ); 336 proc_cor_storage.__cor.state = Halted; 338 337 339 338 // Main routine of the core returned, the core is now fully terminated 340 __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);339 __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, proc->runner); 341 340 342 341 return NULL; … … 353 352 void kernel_first_resume(processor * this) { 354 353 coroutine_desc * src = this_coroutine; 355 coroutine_desc * dst = get_coroutine( this->runner);354 coroutine_desc * dst = get_coroutine(*this->runner); 356 355 357 356 verify( !preemption_state.enabled ); 358 357 359 358 create_stack(&dst->stack, dst->stack.size); 360 CtxStart( &this->runner, CtxInvokeCoroutine);359 CtxStart(this->runner, CtxInvokeCoroutine); 361 360 362 361 verify( !preemption_state.enabled ); … … 412 411 verify( !preemption_state.enabled ); 413 412 lock( ready_queue_lock __cfaabi_dbg_ctx2 ); 413 //TEMP hack to find a bug 414 if(this_processor != mainProcessor) { 415 if(ready_queue.head == mainThread) { 416 unlock( ready_queue_lock ); 417 return NULL; 418 } 419 } 420 414 421 thread_desc * head = pop_head( ready_queue ); 415 422 unlock( ready_queue_lock ); … … 577 584 // Destroy the main processor and its context in reverse order of construction 578 585 // These were manually constructed so we need manually destroy them 579 ^( mainProcessor->runner){};586 ^(*mainProcessor->runner){}; 580 587 ^(mainProcessor){}; 581 588 -
src/libcfa/concurrency/kernel_private.h
r520145b rd893266a 52 52 //----------------------------------------------------------------------------- 53 53 // Processor 54 coroutine processorCtx_t { 55 processor * proc; 56 }; 57 54 58 void main(processorCtx_t *); 55 59 void start(processor * this); -
src/tests/Makefile.am
r520145b rd893266a 123 123 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 124 124 125 # Warnings126 125 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@ 127 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only 126 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@} 127 echo > ${@} -
src/tests/Makefile.in
r520145b rd893266a 800 800 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 801 801 802 # Warnings803 802 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@ 804 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only 803 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@} 804 echo > ${@} 805 805 806 806 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/tests/warnings/.expect/self-assignment.txt
r520145b rd893266a 1 warnings/self-assignment.c:29:1 warning: self assignment of expression: Cast of:2 Variable Expression: j: signed int3 ... to:4 reference to signed int5 warnings/self-assignment.c:30:1 warning: self assignment of expression: Cast of:6 Variable Expression: s: instance of struct S with body 17 ... to:8 reference to instance of struct S with body 19 warnings/self-assignment.c:31:1 warning: self assignment of expression: Cast of:10 Member Expression, with field:11 i: signed int12 ... from aggregate:13 Variable Expression: s: instance of struct S with body 114 ... to:15 reference to signed int16 warnings/self-assignment.c:32:1 warning: self assignment of expression: Cast of:17 Member Expression, with field:18 i: signed int19 ... from aggregate:20 Member Expression, with field:21 s: instance of struct S with body 122 ... from aggregate:23 Variable Expression: t: instance of struct T with body 124 ... to:25 reference to signed int
Note: See TracChangeset
for help on using the changeset viewer.