- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r3e1a705 r89eff25 77 77 static void doregister( struct cluster & cltr ); 78 78 static void unregister( struct cluster & cltr ); 79 static void register_tls( processor * this );80 static void unregister_tls( processor * this );81 79 static void ?{}( $coroutine & this, current_stack_info_t * info); 82 80 static void ?{}( $thread & this, current_stack_info_t * info); … … 125 123 NULL, // cannot use 0p 126 124 NULL, 127 false, 125 NULL, 126 NULL, 128 127 { 1, false, false }, 129 0,130 { 0, 0 },131 NULL,132 #ifdef __CFA_WITH_VERIFY__133 false,134 0,135 #endif136 128 }; 137 129 … … 218 210 (*mainProcessor){}; 219 211 220 register_tls( mainProcessor );221 222 212 //initialize the global state variables 223 213 __cfaabi_tls.this_processor = mainProcessor; 214 __cfaabi_tls.this_proc_id = (__processor_id_t*)mainProcessor; 224 215 __cfaabi_tls.this_thread = mainThread; 225 216 … … 228 219 __init_stats( __cfaabi_tls.this_stats ); 229 220 #endif 230 mainProcessor->local_data = &__cfaabi_tls;231 221 232 222 // Enable preemption … … 235 225 // Add the main thread to the ready queue 236 226 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread 237 schedule_thread$(mainThread);227 __schedule_thread(mainThread); 238 228 239 229 // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX … … 248 238 249 239 /* paranoid */ verify( ! __preemption_enabled() ); 250 enable_interrupts( );240 enable_interrupts( __cfaabi_dbg_ctx ); 251 241 /* paranoid */ verify( __preemption_enabled() ); 252 242 … … 283 273 #endif 284 274 285 mainProcessor->local_data = 0p;286 287 unregister_tls( mainProcessor );288 289 275 // Destroy the main processor and its context in reverse order of construction 290 276 // These were manually constructed so we need manually destroy them … … 330 316 processor * proc = (processor *) arg; 331 317 __cfaabi_tls.this_processor = proc; 318 __cfaabi_tls.this_proc_id = (__processor_id_t*)proc; 332 319 __cfaabi_tls.this_thread = 0p; 333 320 __cfaabi_tls.preemption_state.[enabled, disable_count] = [false, 1]; 334 proc->local_data = &__cfaabi_tls;335 336 register_tls( proc );337 338 321 // SKULLDUGGERY: We want to create a context for the processor coroutine 339 322 // which is needed for the 2-step context switch. However, there is no reason … … 372 355 #endif 373 356 #endif 374 375 proc->local_data = 0p;376 377 unregister_tls( proc );378 357 379 358 return 0p; … … 467 446 self_mon_p = &self_mon; 468 447 link.next = 0p; 469 link. ts = 0;470 preferred = -1u;448 link.prev = 0p; 449 link.preferred = -1u; 471 450 last_proc = 0p; 472 451 #if defined( __CFA_WITH_VERIFY__ ) … … 496 475 this.rdq.id = -1u; 497 476 this.rdq.target = -1u; 498 this.rdq.cutoff = 0ull;477 this.rdq.cutoff = -1ull; 499 478 do_terminate = false; 500 479 preemption_alarm = 0p; … … 506 485 507 486 this.init.thrd = initT; 508 509 this.local_data = 0p;510 487 511 488 this.idle = eventfd(0, 0); … … 519 496 #endif 520 497 498 // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue 499 uint_fast32_t last_size = ready_mutate_register((__processor_id_t*)&this); 500 this.cltr->procs.total += 1u; 501 insert_last(this.cltr->procs.actives, this); 502 503 // Adjust the ready queue size 504 ready_queue_grow( cltr ); 505 506 // Unlock the RWlock 507 ready_mutate_unlock( last_size ); 508 521 509 __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this); 522 510 } … … 524 512 // Not a ctor, it just preps the destruction but should not destroy members 525 513 static void deinit(processor & this) { 514 // Lock the RWlock so no-one pushes/pops while we are changing the queue 515 uint_fast32_t last_size = ready_mutate_lock(); 516 this.cltr->procs.total -= 1u; 517 remove(this); 518 519 // Adjust the ready queue size 520 ready_queue_shrink( this.cltr ); 521 522 // Unlock the RWlock and unregister: we don't need the read_lock any more 523 ready_mutate_unregister((__processor_id_t*)&this, last_size ); 524 526 525 close(this.idle); 527 526 } … … 533 532 disable_interrupts(); 534 533 init( this, name, _cltr, initT ); 535 enable_interrupts( );534 enable_interrupts( __cfaabi_dbg_ctx ); 536 535 537 536 __cfadbg_print_safe(runtime_core, "Kernel : Starting core %p\n", &this); … … 560 559 disable_interrupts(); 561 560 deinit( this ); 562 enable_interrupts( );561 enable_interrupts( __cfaabi_dbg_ctx ); 563 562 } 564 563 … … 598 597 // Unlock the RWlock 599 598 ready_mutate_unlock( last_size ); 600 enable_interrupts ( false); // Don't poll, could be in main cluster599 enable_interrupts_noPoll(); // Don't poll, could be in main cluster 601 600 } 602 601 … … 613 612 // Unlock the RWlock 614 613 ready_mutate_unlock( last_size ); 615 enable_interrupts ( false); // Don't poll, could be in main cluster614 enable_interrupts_noPoll(); // Don't poll, could be in main cluster 616 615 617 616 #if !defined(__CFA_NO_STATISTICS__) … … 657 656 cltr->nthreads -= 1; 658 657 unlock(cltr->thread_list_lock); 659 }660 661 static void register_tls( processor * this ) {662 // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue663 uint_fast32_t last_size;664 [this->unique_id, last_size] = ready_mutate_register();665 666 this->cltr->procs.total += 1u;667 insert_last(this->cltr->procs.actives, *this);668 669 // Adjust the ready queue size670 ready_queue_grow( this->cltr );671 672 // Unlock the RWlock673 ready_mutate_unlock( last_size );674 }675 676 677 static void unregister_tls( processor * this ) {678 // Lock the RWlock so no-one pushes/pops while we are changing the queue679 uint_fast32_t last_size = ready_mutate_lock();680 this->cltr->procs.total -= 1u;681 remove(*this);682 683 // clear the cluster so nothing gets pushed to local queues684 cluster * cltr = this->cltr;685 this->cltr = 0p;686 687 // Adjust the ready queue size688 ready_queue_shrink( cltr );689 690 // Unlock the RWlock and unregister: we don't need the read_lock any more691 ready_mutate_unregister( this->unique_id, last_size );692 658 } 693 659
Note:
See TracChangeset
for help on using the changeset viewer.