Changeset ac2b598 for libcfa/src/concurrency/kernel.cfa
- Timestamp:
- Feb 24, 2020, 2:21:03 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 959f6ad
- Parents:
- 0f2c555
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r0f2c555 rac2b598 117 117 KERNEL_STORAGE(cluster, mainCluster); 118 118 KERNEL_STORAGE(processor, mainProcessor); 119 KERNEL_STORAGE( thread_desc, mainThread);119 KERNEL_STORAGE($thread, mainThread); 120 120 KERNEL_STORAGE(__stack_t, mainThreadCtx); 121 121 122 122 cluster * mainCluster; 123 123 processor * mainProcessor; 124 thread_desc* mainThread;124 $thread * mainThread; 125 125 126 126 extern "C" { … … 164 164 // Main thread construction 165 165 166 void ?{}( coroutine_desc& this, current_stack_info_t * info) with( this ) {166 void ?{}( $coroutine & this, current_stack_info_t * info) with( this ) { 167 167 stack.storage = info->storage; 168 168 with(*stack.storage) { … … 179 179 } 180 180 181 void ?{}( thread_desc& this, current_stack_info_t * info) with( this ) {181 void ?{}( $thread & this, current_stack_info_t * info) with( this ) { 182 182 state = Start; 183 183 self_cor{ info }; … … 264 264 // Kernel Scheduling logic 265 265 //============================================================================================= 266 static thread_desc* __next_thread(cluster * this);267 static void __run_thread(processor * this, thread_desc* dst);266 static $thread * __next_thread(cluster * this); 267 static void __run_thread(processor * this, $thread * dst); 268 268 static void __halt(processor * this); 269 269 … … 287 287 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this); 288 288 289 thread_desc* readyThread = 0p;289 $thread * readyThread = 0p; 290 290 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) { 291 291 readyThread = __next_thread( this->cltr ); … … 323 323 // runThread runs a thread by context switching 324 324 // from the processor coroutine to the target thread 325 static void __run_thread(processor * this, thread_desc* thrd_dst) {326 coroutine_desc* proc_cor = get_coroutine(this->runner);325 static void __run_thread(processor * this, $thread * thrd_dst) { 326 $coroutine * proc_cor = get_coroutine(this->runner); 327 327 328 328 // Update global state … … 400 400 void returnToKernel() { 401 401 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 402 coroutine_desc* proc_cor = get_coroutine(kernelTLS.this_processor->runner);403 thread_desc* thrd_src = kernelTLS.this_thread;402 $coroutine * proc_cor = get_coroutine(kernelTLS.this_processor->runner); 403 $thread * thrd_src = kernelTLS.this_thread; 404 404 405 405 // Run the thread on this processor … … 495 495 // KERNEL_ONLY 496 496 static void __kernel_first_resume( processor * this ) { 497 thread_desc* src = mainThread;498 coroutine_desc* dst = get_coroutine(this->runner);497 $thread * src = mainThread; 498 $coroutine * dst = get_coroutine(this->runner); 499 499 500 500 verify( ! kernelTLS.preemption_state.enabled ); … … 527 527 // KERNEL_ONLY 528 528 static void __kernel_last_resume( processor * this ) { 529 coroutine_desc* src = &mainThread->self_cor;530 coroutine_desc* dst = get_coroutine(this->runner);529 $coroutine * src = &mainThread->self_cor; 530 $coroutine * dst = get_coroutine(this->runner); 531 531 532 532 verify( ! kernelTLS.preemption_state.enabled ); … … 541 541 // Scheduler routines 542 542 // KERNEL ONLY 543 void __schedule_thread( thread_desc* thrd ) with( *thrd->curr_cluster ) {543 void __schedule_thread( $thread * thrd ) with( *thrd->curr_cluster ) { 544 544 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 545 545 /* paranoid */ #if defined( __CFA_WITH_VERIFY__ ) … … 571 571 572 572 // KERNEL ONLY 573 static thread_desc* __next_thread(cluster * this) with( *this ) {573 static $thread * __next_thread(cluster * this) with( *this ) { 574 574 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 575 575 576 576 lock( ready_queue_lock __cfaabi_dbg_ctx2 ); 577 thread_desc* head = pop_head( ready_queue );577 $thread * head = pop_head( ready_queue ); 578 578 unlock( ready_queue_lock ); 579 579 … … 582 582 } 583 583 584 void unpark( thread_desc* thrd ) {584 void unpark( $thread * thrd ) { 585 585 if( !thrd ) return; 586 586 … … 639 639 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 640 640 641 thread_desc* thrd = kernelTLS.this_thread;641 $thread * thrd = kernelTLS.this_thread; 642 642 /* paranoid */ verify(thrd->state == Active || thrd->state == Rerun); 643 643 … … 683 683 // SKULLDUGGERY: the mainThread steals the process main thread 684 684 // which will then be scheduled by the mainProcessor normally 685 mainThread = ( thread_desc*)&storage_mainThread;685 mainThread = ($thread *)&storage_mainThread; 686 686 current_stack_info_t info; 687 687 info.storage = (__stack_t*)&storage_mainThreadCtx; … … 835 835 836 836 void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) { 837 thread_desc* thrd = kernel_data;837 $thread * thrd = kernel_data; 838 838 839 839 if(thrd) { … … 900 900 901 901 void V(semaphore & this) with( this ) { 902 thread_desc* thrd = 0p;902 $thread * thrd = 0p; 903 903 lock( lock __cfaabi_dbg_ctx2 ); 904 904 count += 1; … … 928 928 } 929 929 930 void doregister( cluster * cltr, thread_desc& thrd ) {930 void doregister( cluster * cltr, $thread & thrd ) { 931 931 lock (cltr->thread_list_lock __cfaabi_dbg_ctx2); 932 932 cltr->nthreads += 1; … … 935 935 } 936 936 937 void unregister( cluster * cltr, thread_desc& thrd ) {937 void unregister( cluster * cltr, $thread & thrd ) { 938 938 lock (cltr->thread_list_lock __cfaabi_dbg_ctx2); 939 939 remove(cltr->threads, thrd );
Note: See TracChangeset
for help on using the changeset viewer.