kern: implement thread pinning/SvcSynchronizePreemptionState

This commit is contained in:
Michael Scire
2020-07-27 17:32:04 -07:00
committed by SciresM
parent b1f38be3ae
commit 787964f7e7
10 changed files with 230 additions and 19 deletions

View File

@@ -112,6 +112,21 @@ namespace ams::kern::svc {
return ResultSuccess();
}
void SynchronizePreemptionState() {
/* Lock the scheduler. */
KScopedSchedulerLock sl;
/* If the current thread is pinned, unpin it. */
KProcess *cur_process = GetCurrentProcessPointer();
if (cur_process->GetPinnedThread(GetCurrentCoreId()) == GetCurrentThreadPointer()) {
/* Clear the current thread's interrupt flag. */
GetCurrentThread().ClearInterruptFlag();
/* Unpin the current thread. */
KScheduler::UnpinCurrentThread(cur_process);
}
}
}
/* ============================= 64 ABI ============================= */
@@ -133,7 +148,7 @@ namespace ams::kern::svc {
}
void SynchronizePreemptionState64() {
MESOSPHERE_PANIC("Stubbed SvcSynchronizePreemptionState64 was called.");
return SynchronizePreemptionState();
}
/* ============================= 64From32 ABI ============================= */
@@ -155,7 +170,7 @@ namespace ams::kern::svc {
}
void SynchronizePreemptionState64From32() {
MESOSPHERE_PANIC("Stubbed SvcSynchronizePreemptionState64From32 was called.");
return SynchronizePreemptionState();
}
}