Changeset a3821fa for libcfa/src/concurrency/kernel.cfa
- Timestamp:
- Apr 24, 2021, 7:03:47 PM (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:
- 734908c
- Parents:
- c6c7e6c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
rc6c7e6c ra3821fa 126 126 extern void __disable_interrupts_hard(); 127 127 extern void __enable_interrupts_hard(); 128 129 static inline void __disable_interrupts_checked() { 130 /* paranoid */ verify( __preemption_enabled() ); 131 disable_interrupts(); 132 /* paranoid */ verify( ! __preemption_enabled() ); 133 } 134 135 static inline void __enable_interrupts_checked( bool poll = true ) { 136 /* paranoid */ verify( ! __preemption_enabled() ); 137 enable_interrupts( poll ); 138 /* paranoid */ verify( __preemption_enabled() ); 139 } 128 140 129 141 //============================================================================================= … … 517 529 518 530 if(__must_unpark(thrd)) { 519 /* paranoid */ verify( publicTLS_get(this_proc_id) );520 531 disable_interrupts(); 521 522 /* paranoid */ verify( ! __preemption_enabled() ); 523 524 // Wake lost the race, 525 __schedule_thread( thrd ); 526 527 /* paranoid */ verify( ! __preemption_enabled() ); 528 529 enable_interrupts_noPoll(); 530 /* paranoid */ verify( publicTLS_get(this_proc_id) ); 532 // Wake lost the race, 533 __schedule_thread( thrd ); 534 enable_interrupts(false); 531 535 } 532 536 } 533 537 534 538 void park( void ) { 535 /* paranoid */ verify( __preemption_enabled() ); 536 disable_interrupts(); 537 /* paranoid */ verify( ! __preemption_enabled() ); 538 /* paranoid */ verify( kernelTLS().this_thread->preempted == __NO_PREEMPTION ); 539 540 returnToKernel(); 541 542 /* paranoid */ verify( ! __preemption_enabled() ); 543 enable_interrupts( __cfaabi_dbg_ctx ); 544 /* paranoid */ verify( __preemption_enabled() ); 539 __disable_interrupts_checked(); 540 /* paranoid */ verify( kernelTLS().this_thread->preempted == __NO_PREEMPTION ); 541 returnToKernel(); 542 __enable_interrupts_checked(); 545 543 546 544 } … … 582 580 // KERNEL ONLY 583 581 bool force_yield( __Preemption_Reason reason ) { 584 /* paranoid */ verify( __preemption_enabled() ); 585 disable_interrupts(); 586 /* paranoid */ verify( ! __preemption_enabled() ); 587 588 $thread * thrd = kernelTLS().this_thread; 589 /* paranoid */ verify(thrd->state == Active); 590 591 // SKULLDUGGERY: It is possible that we are preempting this thread just before 592 // it was going to park itself. If that is the case and it is already using the 593 // intrusive fields then we can't use them to preempt the thread 594 // If that is the case, abandon the preemption. 595 bool preempted = false; 596 if(thrd->link.next == 0p) { 597 preempted = true; 598 thrd->preempted = reason; 599 returnToKernel(); 600 } 601 602 /* paranoid */ verify( ! __preemption_enabled() ); 603 enable_interrupts_noPoll(); 604 /* paranoid */ verify( __preemption_enabled() ); 605 582 __disable_interrupts_checked(); 583 $thread * thrd = kernelTLS().this_thread; 584 /* paranoid */ verify(thrd->state == Active); 585 586 // SKULLDUGGERY: It is possible that we are preempting this thread just before 587 // it was going to park itself. If that is the case and it is already using the 588 // intrusive fields then we can't use them to preempt the thread 589 // If that is the case, abandon the preemption. 590 bool preempted = false; 591 if(thrd->link.next == 0p) { 592 preempted = true; 593 thrd->preempted = reason; 594 returnToKernel(); 595 } 596 __enable_interrupts_checked( false ); 606 597 return preempted; 607 598 } … … 648 639 __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this); 649 640 650 disable_interrupts();641 __disable_interrupts_checked(); 651 642 /* paranoid */ verify( ! __preemption_enabled() ); 652 643 eventfd_t val; 653 644 val = 1; 654 645 eventfd_write( this->idle, val ); 655 enable_interrupts( __cfaabi_dbg_ctx);646 __enable_interrupts_checked(); 656 647 } 657 648
Note: See TracChangeset
for help on using the changeset viewer.