Ignore:
File:
1 edited

Legend:

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

    r8fc652e0 re873838  
    118118//-----------------------------------------------------------------------------
    119119// Global state
    120 thread_local struct KernelThreadData __cfaabi_tls __attribute__ ((tls_model ( "initial-exec" ))) @= {
     120thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) @= {
    121121        NULL,                                                                                           // cannot use 0p
    122122        NULL,
     
    156156// Kernel boot procedures
    157157static void __kernel_startup(void) {
    158         /* paranoid */ verify( ! __preemption_enabled() );
     158        verify( ! kernelTLS.preemption_state.enabled );
    159159        __cfadbg_print_safe(runtime_core, "Kernel : Starting\n");
    160160
     
    212212
    213213        //initialize the global state variables
    214         __cfaabi_tls.this_processor = mainProcessor;
    215         __cfaabi_tls.this_proc_id   = (__processor_id_t*)mainProcessor;
    216         __cfaabi_tls.this_thread    = mainThread;
     214        kernelTLS.this_processor = mainProcessor;
     215        kernelTLS.this_proc_id   = (__processor_id_t*)mainProcessor;
     216        kernelTLS.this_thread    = mainThread;
    217217
    218218        #if !defined( __CFA_NO_STATISTICS__ )
    219                 __cfaabi_tls.this_stats = (__stats_t *)& storage_mainProcStats;
    220                 __init_stats( __cfaabi_tls.this_stats );
     219                kernelTLS.this_stats = (__stats_t *)& storage_mainProcStats;
     220                __init_stats( kernelTLS.this_stats );
    221221        #endif
    222222
     
    234234        // context. Hence, the main thread does not begin through __cfactx_invoke_thread, like all other threads. The trick here is that
    235235        // mainThread is on the ready queue when this call is made.
    236         __kernel_first_resume( __cfaabi_tls.this_processor );
     236        __kernel_first_resume( kernelTLS.this_processor );
    237237
    238238
     
    251251        __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n");
    252252
    253         /* paranoid */ verify( ! __preemption_enabled() );
     253        verify( ! kernelTLS.preemption_state.enabled );
    254254        enable_interrupts( __cfaabi_dbg_ctx );
    255         /* paranoid */ verify( __preemption_enabled() );
    256 
     255        verify( TL_GET( preemption_state.enabled ) );
    257256}
    258257
     
    263262        mainCluster->io.ctxs = 0p;
    264263
    265         /* paranoid */ verify( __preemption_enabled() );
     264        /* paranoid */ verify( TL_GET( preemption_state.enabled ) );
    266265        disable_interrupts();
    267         /* paranoid */ verify( ! __preemption_enabled() );
     266        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    268267
    269268        __cfadbg_print_safe(runtime_core, "\n--------------------------------------------------\nKernel : Shutting down\n");
     
    273272        // which is currently here
    274273        __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
    275         __kernel_last_resume( __cfaabi_tls.this_processor );
     274        __kernel_last_resume( kernelTLS.this_processor );
    276275        mainThread->self_cor.state = Halted;
    277276
     
    322321                __stats_t local_stats;
    323322                __init_stats( &local_stats );
    324                 __cfaabi_tls.this_stats = &local_stats;
     323                kernelTLS.this_stats = &local_stats;
    325324        #endif
    326325
    327326        processor * proc = (processor *) arg;
    328         __cfaabi_tls.this_processor = proc;
    329         __cfaabi_tls.this_proc_id   = (__processor_id_t*)proc;
    330         __cfaabi_tls.this_thread    = 0p;
    331         __cfaabi_tls.preemption_state.[enabled, disable_count] = [false, 1];
     327        kernelTLS.this_processor = proc;
     328        kernelTLS.this_proc_id   = (__processor_id_t*)proc;
     329        kernelTLS.this_thread    = 0p;
     330        kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
    332331        // SKULLDUGGERY: We want to create a context for the processor coroutine
    333332        // which is needed for the 2-step context switch. However, there is no reason
     
    341340
    342341        //Set global state
    343         __cfaabi_tls.this_thread = 0p;
     342        kernelTLS.this_thread = 0p;
    344343
    345344        //We now have a proper context from which to schedule threads
     
    371370        $coroutine * dst = get_coroutine(this->runner);
    372371
    373         /* paranoid */ verify( ! __preemption_enabled() );
    374 
    375         __cfaabi_tls.this_thread->curr_cor = dst;
     372        verify( ! kernelTLS.preemption_state.enabled );
     373
     374        kernelTLS.this_thread->curr_cor = dst;
    376375        __stack_prepare( &dst->stack, 65000 );
    377376        __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine);
    378377
    379         /* paranoid */ verify( ! __preemption_enabled() );
     378        verify( ! kernelTLS.preemption_state.enabled );
    380379
    381380        dst->last = &src->self_cor;
     
    395394        /* paranoid */ verify(src->state == Active);
    396395
    397         /* paranoid */ verify( ! __preemption_enabled() );
     396        verify( ! kernelTLS.preemption_state.enabled );
    398397}
    399398
     
    403402        $coroutine * dst = get_coroutine(this->runner);
    404403
    405         /* paranoid */ verify( ! __preemption_enabled() );
    406         /* paranoid */ verify( dst->starter == src );
    407         /* paranoid */ verify( dst->context.SP );
     404        verify( ! kernelTLS.preemption_state.enabled );
     405        verify( dst->starter == src );
     406        verify( dst->context.SP );
    408407
    409408        // SKULLDUGGERY in debug the processors check that the
     
    547546
    548547                P( terminated );
    549                 /* paranoid */ verify( active_processor() != &this);
     548                verify( kernelTLS.this_processor != &this);
    550549        }
    551550
     
    697696#if defined(__CFA_WITH_VERIFY__)
    698697static bool verify_fwd_bck_rng(void) {
    699         __cfaabi_tls.ready_rng.fwd_seed = 25214903917_l64u * (rdtscl() ^ (uintptr_t)&verify_fwd_bck_rng);
     698        kernelTLS.ready_rng.fwd_seed = 25214903917_l64u * (rdtscl() ^ (uintptr_t)&verify_fwd_bck_rng);
    700699
    701700        unsigned values[10];
Note: See TracChangeset for help on using the changeset viewer.