Changeset 4069faad for libcfa/src/concurrency/kernel.cfa
- Timestamp:
- May 1, 2020, 12:37:30 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d45ed83
- Parents:
- 9987d79
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r9987d79 r4069faad 15 15 16 16 #define __cforall_thread__ 17 // #define __CFA_DEBUG_PRINT_RUNTIME_CORE__ 17 18 18 19 //C Includes … … 40 41 #include "invoke.h" 41 42 43 42 44 //----------------------------------------------------------------------------- 43 45 // Some assembly required … … 230 232 idle{}; 231 233 232 __cfa abi_dbg_print_safe("Kernel : Starting core %p\n", &this);234 __cfadbg_print_safe(runtime_core, "Kernel : Starting core %p\n", &this); 233 235 234 236 this.stack = __create_pthread( &this.kernel_thread, __invoke_processor, (void *)&this ); 235 237 236 __cfa abi_dbg_print_safe("Kernel : core %p started\n", &this);238 __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this); 237 239 } 238 240 239 241 void ^?{}(processor & this) with( this ){ 240 242 if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) { 241 __cfa abi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);243 __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this); 242 244 243 245 __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED); … … 289 291 verify(this); 290 292 291 __cfa abi_dbg_print_safe("Kernel : core %p starting\n", this);293 __cfadbg_print_safe(runtime_core, "Kernel : core %p starting\n", this); 292 294 293 295 doregister(this->cltr, this); … … 297 299 preemption_scope scope = { this }; 298 300 299 __cfa abi_dbg_print_safe("Kernel : core %p started\n", this);301 __cfadbg_print_safe(runtime_core, "Kernel : core %p started\n", this); 300 302 301 303 $thread * readyThread = 0p; … … 323 325 } 324 326 325 __cfa abi_dbg_print_safe("Kernel : core %p stopping\n", this);327 __cfadbg_print_safe(runtime_core, "Kernel : core %p stopping\n", this); 326 328 } 327 329 … … 330 332 V( this->terminated ); 331 333 332 __cfa abi_dbg_print_safe("Kernel : core %p terminated\n", this);334 __cfadbg_print_safe(runtime_core, "Kernel : core %p terminated\n", this); 333 335 334 336 // HACK : the coroutine context switch expects this_thread to be set … … 475 477 476 478 //We now have a proper context from which to schedule threads 477 __cfa abi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);479 __cfadbg_print_safe(runtime_core, "Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx); 478 480 479 481 // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't … … 486 488 487 489 // Main routine of the core returned, the core is now fully terminated 488 __cfa abi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);490 __cfadbg_print_safe(runtime_core, "Kernel : core %p main ended (%p)\n", proc, &proc->runner); 489 491 490 492 return 0p; … … 717 719 static void __kernel_startup(void) { 718 720 verify( ! kernelTLS.preemption_state.enabled ); 719 __cfa abi_dbg_print_safe("Kernel : Starting\n");721 __cfadbg_print_safe(runtime_core, "Kernel : Starting\n"); 720 722 721 723 __page_size = sysconf( _SC_PAGESIZE ); … … 728 730 (*mainCluster){"Main Cluster"}; 729 731 730 __cfa abi_dbg_print_safe("Kernel : Main cluster ready\n");732 __cfadbg_print_safe(runtime_core, "Kernel : Main cluster ready\n"); 731 733 732 734 // Start by initializing the main thread … … 738 740 (*mainThread){ &info }; 739 741 740 __cfa abi_dbg_print_safe("Kernel : Main thread ready\n");742 __cfadbg_print_safe(runtime_core, "Kernel : Main thread ready\n"); 741 743 742 744 … … 759 761 760 762 runner{ &this }; 761 __cfa abi_dbg_print_safe("Kernel : constructed main processor context %p\n", &runner);763 __cfadbg_print_safe(runtime_core, "Kernel : constructed main processor context %p\n", &runner); 762 764 } 763 765 … … 834 836 ^(__cfa_dbg_global_clusters.lock){}; 835 837 836 __cfa abi_dbg_print_safe("Kernel : Shutdown complete\n");838 __cfadbg_print_safe(runtime_core, "Kernel : Shutdown complete\n"); 837 839 } 838 840 … … 859 861 860 862 // We are ready to sleep 861 __cfa abi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this);863 __cfadbg_print_safe(runtime_core, "Kernel : Processor %p ready to sleep\n", this); 862 864 wait( idle ); 863 865 864 866 // We have woken up 865 __cfa abi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this);867 __cfadbg_print_safe(runtime_core, "Kernel : Processor %p woke up and ready to run\n", this); 866 868 867 869 // Get ourself off the idle list … … 879 881 static bool __wake_one(cluster * this, __attribute__((unused)) bool force) { 880 882 // if we don't want to force check if we know it's false 881 if( !this->idles.head && !force ) return false;883 // if( !this->idles.head && !force ) return false; 882 884 883 885 // First, lock the cluster idle … … 892 894 893 895 // Wake them up 896 __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this->idles.head); 894 897 post( this->idles.head->idle ); 895 898 … … 901 904 // Unconditionnaly wake a thread 902 905 static bool __wake_proc(processor * this) { 906 __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this); 903 907 return post( this->idle ); 904 908 }
Note: See TracChangeset
for help on using the changeset viewer.