mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:27:42 +00:00
Revert "Kernel: Fix Thread::relock_process leaving critical section"
This reverts commit e9e76b8074
.
This was causing a noticeable slowdown, and we're not sure that it was
actually necessary.
This commit is contained in:
parent
db1448b21a
commit
f2decb6665
2 changed files with 9 additions and 11 deletions
|
@ -588,19 +588,16 @@ void Scheduler::invoke_async()
|
||||||
void Scheduler::yield_from_critical()
|
void Scheduler::yield_from_critical()
|
||||||
{
|
{
|
||||||
auto& proc = Processor::current();
|
auto& proc = Processor::current();
|
||||||
auto before_critical = proc.in_critical();
|
ASSERT(proc.in_critical());
|
||||||
ASSERT(before_critical);
|
|
||||||
ASSERT(!proc.in_irq());
|
ASSERT(!proc.in_irq());
|
||||||
|
|
||||||
yield(); // Flag a context switch
|
yield(); // Flag a context switch
|
||||||
|
|
||||||
u32 prev_flags;
|
u32 prev_flags;
|
||||||
u32 prev_crit = proc.clear_critical(prev_flags, false);
|
u32 prev_crit = Processor::current().clear_critical(prev_flags, false);
|
||||||
|
|
||||||
// Note, we may now be on a different CPU!
|
// Note, we may now be on a different CPU!
|
||||||
auto& new_proc = Processor::current();
|
Processor::current().restore_critical(prev_crit, prev_flags);
|
||||||
new_proc.restore_critical(prev_crit, prev_flags);
|
|
||||||
ASSERT(before_critical == new_proc.in_critical());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::notify_finalizer()
|
void Scheduler::notify_finalizer()
|
||||||
|
|
|
@ -305,16 +305,17 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore)
|
||||||
// flagged by calling Scheduler::donate_to or Scheduler::yield
|
// flagged by calling Scheduler::donate_to or Scheduler::yield
|
||||||
// above. We have to do it this way because we intentionally
|
// above. We have to do it this way because we intentionally
|
||||||
// leave the critical section here to be able to switch contexts.
|
// leave the critical section here to be able to switch contexts.
|
||||||
auto critical_before = Processor::current().in_critical();
|
u32 prev_flags;
|
||||||
ASSERT(critical_before);
|
u32 prev_crit = Processor::current().clear_critical(prev_flags, true);
|
||||||
|
|
||||||
Scheduler::yield_from_critical();
|
// CONTEXT SWITCH HAPPENS HERE!
|
||||||
|
|
||||||
|
// NOTE: We may be on a different CPU now!
|
||||||
|
Processor::current().restore_critical(prev_crit, prev_flags);
|
||||||
|
|
||||||
ASSERT(Processor::current().in_critical() == critical_before);
|
|
||||||
if (previous_locked != LockMode::Unlocked) {
|
if (previous_locked != LockMode::Unlocked) {
|
||||||
// We've unblocked, relock the process if needed and carry on.
|
// We've unblocked, relock the process if needed and carry on.
|
||||||
RESTORE_LOCK(process().big_lock(), previous_locked, lock_count_to_restore);
|
RESTORE_LOCK(process().big_lock(), previous_locked, lock_count_to_restore);
|
||||||
ASSERT(Processor::current().in_critical() == critical_before);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue