summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_thread.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-03-01 16:38:20 +0100
committerGitHub <noreply@github.com>2023-03-01 16:38:20 +0100
commit97f7a560f3905a1dd6a4e5a0a308ea752004bf08 (patch)
treee60a69f96d16d051220b66e90906a7abeacf1064 /src/core/hle/kernel/k_thread.cpp
parentMerge pull request #9879 from zhaobot/tx-update-20230301024940 (diff)
parentsm:: fix lingering session initialization issues (diff)
downloadyuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar.gz
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar.bz2
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar.lz
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar.xz
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.tar.zst
yuzu-97f7a560f3905a1dd6a4e5a0a308ea752004bf08.zip
Diffstat (limited to 'src/core/hle/kernel/k_thread.cpp')
-rw-r--r--src/core/hle/kernel/k_thread.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 2d3da9d66..599d05947 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -29,6 +29,7 @@
#include "core/hle/kernel/k_thread_queue.h"
#include "core/hle/kernel/k_worker_task_manager.h"
#include "core/hle/kernel/kernel.h"
+#include "core/hle/kernel/svc.h"
#include "core/hle/kernel/svc_results.h"
#include "core/hle/kernel/svc_types.h"
#include "core/hle/result.h"
@@ -298,6 +299,25 @@ Result KThread::InitializeUserThread(Core::System& system, KThread* thread, KThr
ThreadType::User, system.GetCpuManager().GetGuestThreadFunc()));
}
+Result KThread::InitializeServiceThread(Core::System& system, KThread* thread,
+ std::function<void()>&& func, s32 prio, s32 virt_core,
+ KProcess* owner) {
+ system.Kernel().GlobalSchedulerContext().AddThread(thread);
+ std::function<void()> func2{[&system, func{std::move(func)}] {
+ // Similar to UserModeThreadStarter.
+ system.Kernel().CurrentScheduler()->OnThreadStart();
+
+ // Run the guest function.
+ func();
+
+ // Exit.
+ Svc::ExitThread(system);
+ }};
+
+ R_RETURN(InitializeThread(thread, {}, {}, {}, prio, virt_core, owner, ThreadType::HighPriority,
+ std::move(func2)));
+}
+
void KThread::PostDestroy(uintptr_t arg) {
KProcess* owner = reinterpret_cast<KProcess*>(arg & ~1ULL);
const bool resource_limit_release_hint = (arg & 1);