Changeset 8d66610 for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- May 21, 2021, 4:48:10 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f1bce515
- Parents:
- 5407cdc (diff), 7404cdc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r5407cdc r8d66610 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 … … 219 228 __init_stats( __cfaabi_tls.this_stats ); 220 229 #endif 230 mainProcessor->local_data = &__cfaabi_tls; 221 231 222 232 // Enable preemption … … 273 283 #endif 274 284 285 mainProcessor->local_data = 0p; 286 287 unregister_tls( mainProcessor ); 288 275 289 // Destroy the main processor and its context in reverse order of construction 276 290 // These were manually constructed so we need manually destroy them … … 316 330 processor * proc = (processor *) arg; 317 331 __cfaabi_tls.this_processor = proc; 318 __cfaabi_tls.this_proc_id = (__processor_id_t*)proc;319 332 __cfaabi_tls.this_thread = 0p; 320 333 __cfaabi_tls.preemption_state.[enabled, disable_count] = [false, 1]; 334 proc->local_data = &__cfaabi_tls; 335 336 register_tls( proc ); 337 321 338 // SKULLDUGGERY: We want to create a context for the processor coroutine 322 339 // which is needed for the 2-step context switch. However, there is no reason … … 355 372 #endif 356 373 #endif 374 375 proc->local_data = 0p; 376 377 unregister_tls( proc ); 357 378 358 379 return 0p; … … 446 467 self_mon_p = &self_mon; 447 468 link.next = 0p; 448 link. prev = 0p;449 link.preferred = -1u;469 link.ts = 0; 470 preferred = -1u; 450 471 last_proc = 0p; 451 472 #if defined( __CFA_WITH_VERIFY__ ) … … 475 496 this.rdq.id = -1u; 476 497 this.rdq.target = -1u; 477 this.rdq.cutoff = -1ull;498 this.rdq.cutoff = 0ull; 478 499 do_terminate = false; 479 500 preemption_alarm = 0p; … … 485 506 486 507 this.init.thrd = initT; 508 509 this.local_data = 0p; 487 510 488 511 this.idle = eventfd(0, 0); … … 496 519 #endif 497 520 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 521 __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this); 510 522 } … … 512 524 // Not a ctor, it just preps the destruction but should not destroy members 513 525 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 526 close(this.idle); 526 527 } … … 656 657 cltr->nthreads -= 1; 657 658 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 queue 663 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 size 670 ready_queue_grow( this->cltr ); 671 672 // Unlock the RWlock 673 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 queue 679 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 queues 684 cluster * cltr = this->cltr; 685 this->cltr = 0p; 686 687 // Adjust the ready queue size 688 ready_queue_shrink( cltr ); 689 690 // Unlock the RWlock and unregister: we don't need the read_lock any more 691 ready_mutate_unregister( this->unique_id, last_size ); 658 692 } 659 693
Note:
See TracChangeset
for help on using the changeset viewer.