From 47af34003b97a27ee8456cedb367b41f8687b517 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Mar 2021 00:13:29 -0800 Subject: hle: kernel: KThread: Rework dummy threads & fix memory leak. - Dummy threads are created on thread local storage for all host threads. - Fixes a leak by removing creation of fibers, which are not applicable here. --- src/core/hle/kernel/k_thread.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel/k_thread.h') diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index c8ac656a4..1c19b23dc 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -116,7 +116,7 @@ public: using WaiterList = boost::intrusive::list; /** - * Creates and returns a new thread. The new thread is immediately scheduled + * Creates and returns a new thread. * @param system The instance of the whole system * @param name The friendly name desired for the thread * @param entry_point The address at which the thread should start execution @@ -127,12 +127,12 @@ public: * @param owner_process The parent process for the thread, if null, it's a kernel thread * @return A shared pointer to the newly created thread */ - [[nodiscard]] static ResultVal> Create( + [[nodiscard]] static ResultVal> CreateThread( Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, u32 priority, u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process); /** - * Creates and returns a new thread. The new thread is immediately scheduled + * Creates and returns a new thread, with a specified entry point. * @param system The instance of the whole system * @param name The friendly name desired for the thread * @param entry_point The address at which the thread should start execution @@ -145,11 +145,27 @@ public: * @param thread_start_parameter The parameter which will passed to host context on init * @return A shared pointer to the newly created thread */ - [[nodiscard]] static ResultVal> Create( + [[nodiscard]] static ResultVal> CreateThread( Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, u32 priority, u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process, std::function&& thread_start_func, void* thread_start_parameter); + /** + * Creates and returns a new thread for the emulated "user" process. + * @param system The instance of the whole system + * @param name The friendly name desired for the thread + * @param entry_point The address at which the thread should start execution + * @param priority The thread's priority + * @param arg User data to pass to the thread + * @param processor_id The ID(s) of the processors on which the thread is desired to be run + * @param stack_top The address of the thread's stack top + * @param owner_process The parent process for the thread, if null, it's a kernel thread + * @return A shared pointer to the newly created thread + */ + [[nodiscard]] static ResultVal> CreateUserThread( + Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, + u32 priority, u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process); + [[nodiscard]] std::string GetName() const override { return name; } -- cgit v1.2.3