summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-11-11 08:02:45 +0100
committerbunnei <bunneidev@gmail.com>2021-12-07 01:39:17 +0100
commit316a2dd22a25e4cfb31b364ab6595d8bb054411c (patch)
tree3d5077bf251a5bd0d08b9ae3d014b0742475c876 /src/core
parenthle: kernel: KThreadQueue: Remove deprecated code. (diff)
downloadyuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar.gz
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar.bz2
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar.lz
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar.xz
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.tar.zst
yuzu-316a2dd22a25e4cfb31b364ab6595d8bb054411c.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/k_process.cpp27
-rw-r--r--src/core/hle/kernel/k_process.h7
2 files changed, 26 insertions, 8 deletions
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index 7cc2061ea..90dda40dc 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -228,12 +228,15 @@ void KProcess::PinCurrentThread() {
const s32 core_id = GetCurrentCoreId(kernel);
KThread* cur_thread = GetCurrentThreadPointer(kernel);
- // Pin it.
- PinThread(core_id, cur_thread);
- cur_thread->Pin();
+ // If the thread isn't terminated, pin it.
+ if (!cur_thread->IsTerminationRequested()) {
+ // Pin it.
+ PinThread(core_id, cur_thread);
+ cur_thread->Pin();
- // An update is needed.
- KScheduler::SetSchedulerUpdateNeeded(kernel);
+ // An update is needed.
+ KScheduler::SetSchedulerUpdateNeeded(kernel);
+ }
}
void KProcess::UnpinCurrentThread() {
@@ -251,6 +254,20 @@ void KProcess::UnpinCurrentThread() {
KScheduler::SetSchedulerUpdateNeeded(kernel);
}
+void KProcess::UnpinThread(KThread* thread) {
+ ASSERT(kernel.GlobalSchedulerContext().IsLocked());
+
+ // Get the thread's core id.
+ const auto core_id = thread->GetActiveCore();
+
+ // Unpin it.
+ UnpinThread(core_id, thread);
+ thread->Unpin();
+
+ // An update is needed.
+ KScheduler::SetSchedulerUpdateNeeded(kernel);
+}
+
ResultCode KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address,
[[maybe_unused]] size_t size) {
// Lock ourselves, to prevent concurrent access.
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index 8a8c1fcbb..d972c9de0 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -259,7 +259,7 @@ public:
[[nodiscard]] KThread* GetPinnedThread(s32 core_id) const {
ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
- return pinned_threads[core_id];
+ return pinned_threads.at(core_id);
}
/// Gets 8 bytes of random data for svcGetInfo RandomEntropy
@@ -347,6 +347,7 @@ public:
void PinCurrentThread();
void UnpinCurrentThread();
+ void UnpinThread(KThread* thread);
KLightLock& GetStateLock() {
return state_lock;
@@ -368,14 +369,14 @@ private:
void PinThread(s32 core_id, KThread* thread) {
ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
ASSERT(thread != nullptr);
- ASSERT(pinned_threads[core_id] == nullptr);
+ ASSERT(pinned_threads.at(core_id) == nullptr);
pinned_threads[core_id] = thread;
}
void UnpinThread(s32 core_id, KThread* thread) {
ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
ASSERT(thread != nullptr);
- ASSERT(pinned_threads[core_id] == thread);
+ ASSERT(pinned_threads.at(core_id) == thread);
pinned_threads[core_id] = nullptr;
}