Changeset 8fc652e0 for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- Nov 6, 2020, 11:22:57 AM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 54dcab1
- Parents:
- be5e34b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
rbe5e34b r8fc652e0 118 118 //----------------------------------------------------------------------------- 119 119 // Global state 120 thread_local struct KernelThreadData kernelTLS__attribute__ ((tls_model ( "initial-exec" ))) @= {120 thread_local struct KernelThreadData __cfaabi_tls __attribute__ ((tls_model ( "initial-exec" ))) @= { 121 121 NULL, // cannot use 0p 122 122 NULL, … … 156 156 // Kernel boot procedures 157 157 static void __kernel_startup(void) { 158 verify( ! kernelTLS.preemption_state.enabled);158 /* paranoid */ verify( ! __preemption_enabled() ); 159 159 __cfadbg_print_safe(runtime_core, "Kernel : Starting\n"); 160 160 … … 212 212 213 213 //initialize the global state variables 214 kernelTLS.this_processor = mainProcessor;215 kernelTLS.this_proc_id = (__processor_id_t*)mainProcessor;216 kernelTLS.this_thread = mainThread;214 __cfaabi_tls.this_processor = mainProcessor; 215 __cfaabi_tls.this_proc_id = (__processor_id_t*)mainProcessor; 216 __cfaabi_tls.this_thread = mainThread; 217 217 218 218 #if !defined( __CFA_NO_STATISTICS__ ) 219 kernelTLS.this_stats = (__stats_t *)& storage_mainProcStats;220 __init_stats( kernelTLS.this_stats );219 __cfaabi_tls.this_stats = (__stats_t *)& storage_mainProcStats; 220 __init_stats( __cfaabi_tls.this_stats ); 221 221 #endif 222 222 … … 234 234 // context. Hence, the main thread does not begin through __cfactx_invoke_thread, like all other threads. The trick here is that 235 235 // mainThread is on the ready queue when this call is made. 236 __kernel_first_resume( kernelTLS.this_processor );236 __kernel_first_resume( __cfaabi_tls.this_processor ); 237 237 238 238 … … 251 251 __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n"); 252 252 253 verify( ! kernelTLS.preemption_state.enabled);253 /* paranoid */ verify( ! __preemption_enabled() ); 254 254 enable_interrupts( __cfaabi_dbg_ctx ); 255 verify( TL_GET( preemption_state.enabled ) ); 255 /* paranoid */ verify( __preemption_enabled() ); 256 256 257 } 257 258 … … 262 263 mainCluster->io.ctxs = 0p; 263 264 264 /* paranoid */ verify( TL_GET( preemption_state.enabled) );265 /* paranoid */ verify( __preemption_enabled() ); 265 266 disable_interrupts(); 266 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled);267 /* paranoid */ verify( ! __preemption_enabled() ); 267 268 268 269 __cfadbg_print_safe(runtime_core, "\n--------------------------------------------------\nKernel : Shutting down\n"); … … 272 273 // which is currently here 273 274 __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE); 274 __kernel_last_resume( kernelTLS.this_processor );275 __kernel_last_resume( __cfaabi_tls.this_processor ); 275 276 mainThread->self_cor.state = Halted; 276 277 … … 321 322 __stats_t local_stats; 322 323 __init_stats( &local_stats ); 323 kernelTLS.this_stats = &local_stats;324 __cfaabi_tls.this_stats = &local_stats; 324 325 #endif 325 326 326 327 processor * proc = (processor *) arg; 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];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]; 331 332 // SKULLDUGGERY: We want to create a context for the processor coroutine 332 333 // which is needed for the 2-step context switch. However, there is no reason … … 340 341 341 342 //Set global state 342 kernelTLS.this_thread = 0p;343 __cfaabi_tls.this_thread = 0p; 343 344 344 345 //We now have a proper context from which to schedule threads … … 370 371 $coroutine * dst = get_coroutine(this->runner); 371 372 372 verify( ! kernelTLS.preemption_state.enabled);373 374 kernelTLS.this_thread->curr_cor = dst;373 /* paranoid */ verify( ! __preemption_enabled() ); 374 375 __cfaabi_tls.this_thread->curr_cor = dst; 375 376 __stack_prepare( &dst->stack, 65000 ); 376 377 __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine); 377 378 378 verify( ! kernelTLS.preemption_state.enabled);379 /* paranoid */ verify( ! __preemption_enabled() ); 379 380 380 381 dst->last = &src->self_cor; … … 394 395 /* paranoid */ verify(src->state == Active); 395 396 396 verify( ! kernelTLS.preemption_state.enabled);397 /* paranoid */ verify( ! __preemption_enabled() ); 397 398 } 398 399 … … 402 403 $coroutine * dst = get_coroutine(this->runner); 403 404 404 verify( ! kernelTLS.preemption_state.enabled);405 verify( dst->starter == src );406 verify( dst->context.SP );405 /* paranoid */ verify( ! __preemption_enabled() ); 406 /* paranoid */ verify( dst->starter == src ); 407 /* paranoid */ verify( dst->context.SP ); 407 408 408 409 // SKULLDUGGERY in debug the processors check that the … … 546 547 547 548 P( terminated ); 548 verify( kernelTLS.this_processor!= &this);549 /* paranoid */ verify( active_processor() != &this); 549 550 } 550 551 … … 696 697 #if defined(__CFA_WITH_VERIFY__) 697 698 static bool verify_fwd_bck_rng(void) { 698 kernelTLS.ready_rng.fwd_seed = 25214903917_l64u * (rdtscl() ^ (uintptr_t)&verify_fwd_bck_rng);699 __cfaabi_tls.ready_rng.fwd_seed = 25214903917_l64u * (rdtscl() ^ (uintptr_t)&verify_fwd_bck_rng); 699 700 700 701 unsigned values[10];
Note: See TracChangeset
for help on using the changeset viewer.