Changeset 93d2219 for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- Oct 28, 2022, 3:12:16 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- fa2e183
- Parents:
- e874605 (diff), 22a0e87 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
re874605 r93d2219 16 16 #define __cforall_thread__ 17 17 #define _GNU_SOURCE 18 19 // #define __CFA_DEBUG_PRINT_RUNTIME_CORE__ 18 20 19 21 // C Includes … … 222 224 ( this.runner ){}; 223 225 init( this, "Main Processor", *mainCluster, 0p ); 224 kernel_thread = pthread_self();226 kernel_thread = __cfaabi_pthread_self(); 225 227 226 228 runner{ &this }; … … 283 285 } 284 286 287 extern "C"{ 288 void pthread_delete_kernel_threads_(); 289 } 290 291 285 292 static void __kernel_shutdown(void) { 286 293 if(!cfa_main_returned) return; 294 295 //delete kernel threads for pthread_concurrency 296 pthread_delete_kernel_threads_(); 297 287 298 /* paranoid */ verify( __preemption_enabled() ); 288 299 disable_interrupts(); … … 327 338 328 339 /* paranoid */ verify( this.do_terminate == true ); 329 __cfa abi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner);340 __cfadbg_print_safe(runtime_core, "Kernel : destroyed main processor context %p\n", &runner); 330 341 } 331 342 … … 388 399 (proc->runner){ proc, &info }; 389 400 390 __cfa abi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage);401 __cfadbg_print_safe(runtime_core, "Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage); 391 402 392 403 //Set global state … … 520 531 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl(); 521 532 #if defined( __CFA_WITH_VERIFY__ ) 533 executing = 0p; 522 534 canary = 0x0D15EA5E0D15EA5Ep; 523 535 #endif … … 652 664 io.params = io_params; 653 665 666 managed.procs = 0p; 667 managed.cnt = 0; 668 654 669 doregister(this); 655 670 … … 667 682 668 683 void ^?{}(cluster & this) libcfa_public { 684 set_concurrency( this, 0 ); 685 669 686 destroy(this.io.arbiter); 670 687 … … 777 794 pthread_attr_t attr; 778 795 779 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute796 check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 780 797 781 798 size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE ); … … 804 821 #endif 805 822 806 check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );807 check( pthread_create( pthread, &attr, start, arg ), "pthread_create" );823 check( __cfaabi_pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 824 check( __cfaabi_pthread_create( pthread, &attr, start, arg ), "pthread_create" ); 808 825 return stack; 809 826 } 810 827 811 828 void __destroy_pthread( pthread_t pthread, void * stack, void ** retval ) { 812 int err = pthread_join( pthread, retval );829 int err = __cfaabi_pthread_join( pthread, retval ); 813 830 if( err != 0 ) abort("KERNEL ERROR: joining pthread %p caused error %s\n", (void*)pthread, strerror(err)); 814 831 … … 816 833 pthread_attr_t attr; 817 834 818 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute835 check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 819 836 820 837 size_t stacksize; 821 838 // default stack size, normally defined by shell limit 822 check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );839 check( __cfaabi_pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 823 840 assert( stacksize >= PTHREAD_STACK_MIN ); 824 841 stacksize += __page_size; … … 838 855 } 839 856 857 unsigned set_concurrency( cluster & this, unsigned new ) libcfa_public { 858 unsigned old = this.managed.cnt; 859 860 __cfadbg_print_safe(runtime_core, "Kernel : resizing cluster from %u to %u\n", old, (unsigned)new); 861 862 // Delete all the old unneeded procs 863 if(old > new) for(i; (unsigned)new ~ old) { 864 __cfadbg_print_safe(runtime_core, "Kernel : destroying %u\n", i); 865 delete( this.managed.procs[i] ); 866 } 867 868 // Allocate new array (uses realloc and memcpies the data) 869 this.managed.procs = alloc( new, this.managed.procs`realloc ); 870 this.managed.cnt = new; 871 872 // Create the desired new procs 873 if(old < new) for(i; old ~ new) { 874 __cfadbg_print_safe(runtime_core, "Kernel : constructing %u\n", i); 875 (*(this.managed.procs[i] = alloc())){ this }; 876 } 877 878 // return the old count 879 return old; 880 } 881 840 882 #if defined(__CFA_WITH_VERIFY__) 841 883 static bool verify_fwd_bck_rng(void) {
Note:
See TracChangeset
for help on using the changeset viewer.