- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r8b74fa7 r116a2ea 16 16 #define __cforall_thread__ 17 17 #define _GNU_SOURCE 18 19 // #define __CFA_DEBUG_PRINT_RUNTIME_CORE__20 18 21 19 // C Includes … … 224 222 ( this.runner ){}; 225 223 init( this, "Main Processor", *mainCluster, 0p ); 226 kernel_thread = __cfaabi_pthread_self();224 kernel_thread = pthread_self(); 227 225 228 226 runner{ &this }; … … 285 283 } 286 284 287 extern "C"{288 void pthread_delete_kernel_threads_();289 }290 291 292 285 static void __kernel_shutdown(void) { 293 286 if(!cfa_main_returned) return; 294 295 //delete kernel threads for pthread_concurrency296 pthread_delete_kernel_threads_();297 298 287 /* paranoid */ verify( __preemption_enabled() ); 299 288 disable_interrupts(); … … 338 327 339 328 /* paranoid */ verify( this.do_terminate == true ); 340 __cfa dbg_print_safe(runtime_core,"Kernel : destroyed main processor context %p\n", &runner);329 __cfaabi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner); 341 330 } 342 331 … … 399 388 (proc->runner){ proc, &info }; 400 389 401 __cfa dbg_print_safe(runtime_core,"Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage);390 __cfaabi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage); 402 391 403 392 //Set global state … … 531 520 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl(); 532 521 #if defined( __CFA_WITH_VERIFY__ ) 533 executing = 0p;534 522 canary = 0x0D15EA5E0D15EA5Ep; 535 523 #endif … … 664 652 io.params = io_params; 665 653 666 managed.procs = 0p;667 managed.cnt = 0;668 669 654 doregister(this); 670 655 … … 682 667 683 668 void ^?{}(cluster & this) libcfa_public { 684 set_concurrency( this, 0 );685 686 669 destroy(this.io.arbiter); 687 670 … … 794 777 pthread_attr_t attr; 795 778 796 check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute779 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 797 780 798 781 size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE ); … … 821 804 #endif 822 805 823 check( __cfaabi_pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );824 check( __cfaabi_pthread_create( pthread, &attr, start, arg ), "pthread_create" );806 check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 807 check( pthread_create( pthread, &attr, start, arg ), "pthread_create" ); 825 808 return stack; 826 809 } 827 810 828 811 void __destroy_pthread( pthread_t pthread, void * stack, void ** retval ) { 829 int err = __cfaabi_pthread_join( pthread, retval );812 int err = pthread_join( pthread, retval ); 830 813 if( err != 0 ) abort("KERNEL ERROR: joining pthread %p caused error %s\n", (void*)pthread, strerror(err)); 831 814 … … 833 816 pthread_attr_t attr; 834 817 835 check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute818 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 836 819 837 820 size_t stacksize; 838 821 // default stack size, normally defined by shell limit 839 check( __cfaabi_pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );822 check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 840 823 assert( stacksize >= PTHREAD_STACK_MIN ); 841 824 stacksize += __page_size; … … 855 838 } 856 839 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 procs863 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 procs873 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 count879 return old;880 }881 882 840 #if defined(__CFA_WITH_VERIFY__) 883 841 static bool verify_fwd_bck_rng(void) {
Note:
See TracChangeset
for help on using the changeset viewer.