mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 16:32:05 +00:00
kern: update kernel waiter management rules
This commit is contained in:
parent
f67d1b7026
commit
3356eddcba
2 changed files with 5 additions and 2 deletions
|
@ -744,7 +744,7 @@ namespace ams::kern {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, wait for us to not have an exception thread. */
|
/* Otherwise, wait for us to not have an exception thread. */
|
||||||
cur_thread->SetAddressKey(address_key);
|
cur_thread->SetAddressKey(address_key | 1);
|
||||||
m_exception_thread->AddWaiter(cur_thread);
|
m_exception_thread->AddWaiter(cur_thread);
|
||||||
if (cur_thread->GetState() == KThread::ThreadState_Runnable) {
|
if (cur_thread->GetState() == KThread::ThreadState_Runnable) {
|
||||||
cur_thread->SetState(KThread::ThreadState_Waiting);
|
cur_thread->SetState(KThread::ThreadState_Waiting);
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ams::kern {
|
||||||
|
|
||||||
constexpr bool IsKernelAddressKey(KProcessAddress key) {
|
constexpr bool IsKernelAddressKey(KProcessAddress key) {
|
||||||
const uintptr_t key_uptr = GetInteger(key);
|
const uintptr_t key_uptr = GetInteger(key);
|
||||||
return KernelVirtualAddressSpaceBase <= key_uptr && key_uptr <= KernelVirtualAddressSpaceLast;
|
return KernelVirtualAddressSpaceBase <= key_uptr && key_uptr <= KernelVirtualAddressSpaceLast && (key_uptr & 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeKernelStack(uintptr_t stack_top) {
|
void InitializeKernelStack(uintptr_t stack_top) {
|
||||||
|
@ -996,6 +996,7 @@ namespace ams::kern {
|
||||||
/* Keep track of how many kernel waiters we have. */
|
/* Keep track of how many kernel waiters we have. */
|
||||||
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
||||||
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters++) >= 0);
|
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters++) >= 0);
|
||||||
|
KScheduler::SetSchedulerUpdateNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the waiter. */
|
/* Insert the waiter. */
|
||||||
|
@ -1010,6 +1011,7 @@ namespace ams::kern {
|
||||||
/* Keep track of how many kernel waiters we have. */
|
/* Keep track of how many kernel waiters we have. */
|
||||||
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
||||||
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters--) > 0);
|
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters--) > 0);
|
||||||
|
KScheduler::SetSchedulerUpdateNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the waiter. */
|
/* Remove the waiter. */
|
||||||
|
@ -1088,6 +1090,7 @@ namespace ams::kern {
|
||||||
/* Keep track of how many kernel waiters we have. */
|
/* Keep track of how many kernel waiters we have. */
|
||||||
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
if (IsKernelAddressKey(thread->GetAddressKey())) {
|
||||||
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters--) > 0);
|
MESOSPHERE_ABORT_UNLESS((m_num_kernel_waiters--) > 0);
|
||||||
|
KScheduler::SetSchedulerUpdateNeeded();
|
||||||
}
|
}
|
||||||
it = m_waiter_list.erase(it);
|
it = m_waiter_list.erase(it);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue