Changeset c993b15 for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- Apr 29, 2021, 4:26:25 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3eb55f98
- Parents:
- b2fc7ad9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
rb2fc7ad9 rc993b15 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 ); 79 81 static void ?{}( $coroutine & this, current_stack_info_t * info); 80 82 static void ?{}( $thread & this, current_stack_info_t * info); … … 123 125 NULL, // cannot use 0p 124 126 NULL, 127 false, 128 { 1, false, false }, 129 0, 130 { 0, 0 }, 125 131 NULL, 126 NULL, 127 { 1, false, false }, 132 #ifdef __CFA_WITH_VERIFY__ 133 false, 134 0, 135 #endif 128 136 }; 129 137 … … 210 218 (*mainProcessor){}; 211 219 220 register_tls( mainProcessor ); 221 212 222 //initialize the global state variables 213 223 __cfaabi_tls.this_processor = mainProcessor; 214 __cfaabi_tls.this_proc_id = (__processor_id_t*)mainProcessor;215 224 __cfaabi_tls.this_thread = mainThread; 216 225 … … 273 282 #endif 274 283 284 unregister_tls( mainProcessor ); 285 275 286 // Destroy the main processor and its context in reverse order of construction 276 287 // These were manually constructed so we need manually destroy them … … 316 327 processor * proc = (processor *) arg; 317 328 __cfaabi_tls.this_processor = proc; 318 __cfaabi_tls.this_proc_id = (__processor_id_t*)proc;319 329 __cfaabi_tls.this_thread = 0p; 320 330 __cfaabi_tls.preemption_state.[enabled, disable_count] = [false, 1]; 331 332 register_tls( proc ); 333 321 334 // SKULLDUGGERY: We want to create a context for the processor coroutine 322 335 // which is needed for the 2-step context switch. However, there is no reason … … 355 368 #endif 356 369 #endif 370 371 unregister_tls( proc ); 357 372 358 373 return 0p; … … 496 511 #endif 497 512 498 // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue499 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 size504 ready_queue_grow( cltr );505 506 // Unlock the RWlock507 ready_mutate_unlock( last_size );508 509 513 __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this); 510 514 } … … 512 516 // Not a ctor, it just preps the destruction but should not destroy members 513 517 static void deinit(processor & this) { 514 // Lock the RWlock so no-one pushes/pops while we are changing the queue515 uint_fast32_t last_size = ready_mutate_lock();516 this.cltr->procs.total -= 1u;517 remove(this);518 519 // Adjust the ready queue size520 ready_queue_shrink( this.cltr );521 522 // Unlock the RWlock and unregister: we don't need the read_lock any more523 ready_mutate_unregister((__processor_id_t*)&this, last_size );524 525 518 close(this.idle); 526 519 } … … 656 649 cltr->nthreads -= 1; 657 650 unlock(cltr->thread_list_lock); 651 } 652 653 static void register_tls( processor * this ) { 654 // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue 655 uint_fast32_t last_size; 656 [this->unique_id, last_size] = ready_mutate_register(); 657 658 this->cltr->procs.total += 1u; 659 insert_last(this->cltr->procs.actives, *this); 660 661 // Adjust the ready queue size 662 ready_queue_grow( this->cltr ); 663 664 // Unlock the RWlock 665 ready_mutate_unlock( last_size ); 666 } 667 668 669 static void unregister_tls( processor * this ) { 670 // Lock the RWlock so no-one pushes/pops while we are changing the queue 671 uint_fast32_t last_size = ready_mutate_lock(); 672 this->cltr->procs.total -= 1u; 673 remove(*this); 674 675 // clear the cluster so nothing gets pushed to local queues 676 cluster * cltr = this->cltr; 677 this->cltr = 0p; 678 679 // Adjust the ready queue size 680 ready_queue_shrink( cltr ); 681 682 // Unlock the RWlock and unregister: we don't need the read_lock any more 683 ready_mutate_unregister( this->unique_id, last_size ); 658 684 } 659 685
Note: See TracChangeset
for help on using the changeset viewer.