Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/startup.cfa

    r8b74fa7 r116a2ea  
    1616#define __cforall_thread__
    1717#define _GNU_SOURCE
    18 
    19 // #define __CFA_DEBUG_PRINT_RUNTIME_CORE__
    2018
    2119// C Includes
     
    224222                ( this.runner ){};
    225223                init( this, "Main Processor", *mainCluster, 0p );
    226                 kernel_thread = __cfaabi_pthread_self();
     224                kernel_thread = pthread_self();
    227225
    228226                runner{ &this };
     
    285283}
    286284
    287 extern "C"{
    288         void pthread_delete_kernel_threads_();
    289 }
    290 
    291 
    292285static void __kernel_shutdown(void) {
    293286        if(!cfa_main_returned) return;
    294 
    295         //delete kernel threads for pthread_concurrency
    296         pthread_delete_kernel_threads_();
    297 
    298287        /* paranoid */ verify( __preemption_enabled() );
    299288        disable_interrupts();
     
    338327
    339328                /* paranoid */ verify( this.do_terminate == true );
    340                 __cfadbg_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);
    341330        }
    342331
     
    399388        (proc->runner){ proc, &info };
    400389
    401         __cfadbg_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);
    402391
    403392        //Set global state
     
    531520        random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl();
    532521        #if defined( __CFA_WITH_VERIFY__ )
    533                 executing = 0p;
    534522                canary = 0x0D15EA5E0D15EA5Ep;
    535523        #endif
     
    664652        io.params = io_params;
    665653
    666         managed.procs = 0p;
    667         managed.cnt = 0;
    668 
    669654        doregister(this);
    670655
     
    682667
    683668void ^?{}(cluster & this) libcfa_public {
    684         set_concurrency( this, 0 );
    685 
    686669        destroy(this.io.arbiter);
    687670
     
    794777        pthread_attr_t attr;
    795778
    796         check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
     779        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    797780
    798781        size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE );
     
    821804        #endif
    822805
    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" );
    825808        return stack;
    826809}
    827810
    828811void __destroy_pthread( pthread_t pthread, void * stack, void ** retval ) {
    829         int err = __cfaabi_pthread_join( pthread, retval );
     812        int err = pthread_join( pthread, retval );
    830813        if( err != 0 ) abort("KERNEL ERROR: joining pthread %p caused error %s\n", (void*)pthread, strerror(err));
    831814
     
    833816                pthread_attr_t attr;
    834817
    835                 check( __cfaabi_pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
     818                check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    836819
    837820                size_t stacksize;
    838821                // 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" );
    840823                assert( stacksize >= PTHREAD_STACK_MIN );
    841824                stacksize += __page_size;
     
    855838}
    856839
    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 
    882840#if defined(__CFA_WITH_VERIFY__)
    883841static bool verify_fwd_bck_rng(void) {
Note: See TracChangeset for help on using the changeset viewer.