- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r6a77224 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 NULL, 122 123 NULL, 123 124 NULL, … … 155 156 // Kernel boot procedures 156 157 static void __kernel_startup(void) { 157 verify( ! kernelTLS.preemption_state.enabled);158 /* paranoid */ verify( ! __preemption_enabled() ); 158 159 __cfadbg_print_safe(runtime_core, "Kernel : Starting\n"); 159 160 … … 211 212 212 213 //initialize the global state variables 213 kernelTLS.this_processor = mainProcessor; 214 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; 215 217 216 218 #if !defined( __CFA_NO_STATISTICS__ ) 217 kernelTLS.this_stats = (__stats_t *)& storage_mainProcStats;218 __init_stats( kernelTLS.this_stats );219 __cfaabi_tls.this_stats = (__stats_t *)& storage_mainProcStats; 220 __init_stats( __cfaabi_tls.this_stats ); 219 221 #endif 220 222 … … 227 229 // Add the main thread to the ready queue 228 230 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread 229 __schedule_thread( (__processor_id_t *)mainProcessor,mainThread);231 __schedule_thread(mainThread); 230 232 231 233 // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX 232 234 // context. Hence, the main thread does not begin through __cfactx_invoke_thread, like all other threads. The trick here is that 233 235 // mainThread is on the ready queue when this call is made. 234 __kernel_first_resume( kernelTLS.this_processor );236 __kernel_first_resume( __cfaabi_tls.this_processor ); 235 237 236 238 … … 249 251 __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n"); 250 252 251 verify( ! kernelTLS.preemption_state.enabled);253 /* paranoid */ verify( ! __preemption_enabled() ); 252 254 enable_interrupts( __cfaabi_dbg_ctx ); 253 verify( TL_GET( preemption_state.enabled ) ); 255 /* paranoid */ verify( __preemption_enabled() ); 256 254 257 } 255 258 … … 260 263 mainCluster->io.ctxs = 0p; 261 264 262 /* paranoid */ verify( TL_GET( preemption_state.enabled) );265 /* paranoid */ verify( __preemption_enabled() ); 263 266 disable_interrupts(); 264 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled);267 /* paranoid */ verify( ! __preemption_enabled() ); 265 268 266 269 __cfadbg_print_safe(runtime_core, "\n--------------------------------------------------\nKernel : Shutting down\n"); … … 270 273 // which is currently here 271 274 __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE); 272 __kernel_last_resume( kernelTLS.this_processor );275 __kernel_last_resume( __cfaabi_tls.this_processor ); 273 276 mainThread->self_cor.state = Halted; 274 277 … … 319 322 __stats_t local_stats; 320 323 __init_stats( &local_stats ); 321 kernelTLS.this_stats = &local_stats;324 __cfaabi_tls.this_stats = &local_stats; 322 325 #endif 323 326 324 327 processor * proc = (processor *) arg; 325 kernelTLS.this_processor = proc; 326 kernelTLS.this_thread = 0p; 327 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]; 328 332 // SKULLDUGGERY: We want to create a context for the processor coroutine 329 333 // which is needed for the 2-step context switch. However, there is no reason … … 337 341 338 342 //Set global state 339 kernelTLS.this_thread = 0p;343 __cfaabi_tls.this_thread = 0p; 340 344 341 345 //We now have a proper context from which to schedule threads … … 367 371 $coroutine * dst = get_coroutine(this->runner); 368 372 369 verify( ! kernelTLS.preemption_state.enabled);370 371 kernelTLS.this_thread->curr_cor = dst;373 /* paranoid */ verify( ! __preemption_enabled() ); 374 375 __cfaabi_tls.this_thread->curr_cor = dst; 372 376 __stack_prepare( &dst->stack, 65000 ); 373 377 __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine); 374 378 375 verify( ! kernelTLS.preemption_state.enabled);379 /* paranoid */ verify( ! __preemption_enabled() ); 376 380 377 381 dst->last = &src->self_cor; … … 391 395 /* paranoid */ verify(src->state == Active); 392 396 393 verify( ! kernelTLS.preemption_state.enabled);397 /* paranoid */ verify( ! __preemption_enabled() ); 394 398 } 395 399 … … 399 403 $coroutine * dst = get_coroutine(this->runner); 400 404 401 verify( ! kernelTLS.preemption_state.enabled);402 verify( dst->starter == src );403 verify( dst->context.SP );405 /* paranoid */ verify( ! __preemption_enabled() ); 406 /* paranoid */ verify( dst->starter == src ); 407 /* paranoid */ verify( dst->context.SP ); 404 408 405 409 // SKULLDUGGERY in debug the processors check that the … … 543 547 544 548 P( terminated ); 545 verify( kernelTLS.this_processor!= &this);549 /* paranoid */ verify( active_processor() != &this); 546 550 } 547 551 … … 693 697 #if defined(__CFA_WITH_VERIFY__) 694 698 static bool verify_fwd_bck_rng(void) { 695 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); 696 700 697 701 unsigned values[10];
Note:
See TracChangeset
for help on using the changeset viewer.