diff options
| author | 2016-12-17 14:34:48 -0500 | |
|---|---|---|
| committer | 2016-12-17 14:34:48 -0500 | |
| commit | 20b832cfc1cb7fca6dd59a4af2f2c95e3c5eaaab (patch) | |
| tree | 61df2f8ed57ff935c1ac018a64f86d683df45c1e /src | |
| parent | Merge pull request #2335 from yuriks/shader-refactor (diff) | |
| parent | Thread: remove the thread from the thread list when exiting (diff) | |
| download | yuzu-20b832cfc1cb7fca6dd59a4af2f2c95e3c5eaaab.tar.gz yuzu-20b832cfc1cb7fca6dd59a4af2f2c95e3c5eaaab.tar.xz yuzu-20b832cfc1cb7fca6dd59a4af2f2c95e3c5eaaab.zip | |
Merge pull request #2345 from wwylele/no-zombie-thread
Thread: remove the thread from the thread list when exiting
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 5 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 4bbc08516..18b696f72 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -46,7 +46,7 @@ static std::vector<SharedPtr<Thread>> thread_list; | |||
| 46 | // Lists only ready thread ids. | 46 | // Lists only ready thread ids. |
| 47 | static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue; | 47 | static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue; |
| 48 | 48 | ||
| 49 | static Thread* current_thread; | 49 | static SharedPtr<Thread> current_thread; |
| 50 | 50 | ||
| 51 | // The first available thread id at startup | 51 | // The first available thread id at startup |
| 52 | static u32 next_thread_id; | 52 | static u32 next_thread_id; |
| @@ -63,7 +63,7 @@ Thread::Thread() {} | |||
| 63 | Thread::~Thread() {} | 63 | Thread::~Thread() {} |
| 64 | 64 | ||
| 65 | Thread* GetCurrentThread() { | 65 | Thread* GetCurrentThread() { |
| 66 | return current_thread; | 66 | return current_thread.get(); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | /** | 69 | /** |
| @@ -263,6 +263,13 @@ void WaitCurrentThread_ArbitrateAddress(VAddr wait_address) { | |||
| 263 | thread->status = THREADSTATUS_WAIT_ARB; | 263 | thread->status = THREADSTATUS_WAIT_ARB; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | void ExitCurrentThread() { | ||
| 267 | Thread* thread = GetCurrentThread(); | ||
| 268 | thread->Stop(); | ||
| 269 | thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), | ||
| 270 | thread_list.end()); | ||
| 271 | } | ||
| 272 | |||
| 266 | /** | 273 | /** |
| 267 | * Callback that will wake up the thread it was scheduled for | 274 | * Callback that will wake up the thread it was scheduled for |
| 268 | * @param thread_handle The handle of the thread that's been awoken | 275 | * @param thread_handle The handle of the thread that's been awoken |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 238359fc5..d4fefc573 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -253,6 +253,11 @@ void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wa | |||
| 253 | void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); | 253 | void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); |
| 254 | 254 | ||
| 255 | /** | 255 | /** |
| 256 | * Stops the current thread and removes it from the thread_list | ||
| 257 | */ | ||
| 258 | void ExitCurrentThread(); | ||
| 259 | |||
| 260 | /** | ||
| 256 | * Initialize threading | 261 | * Initialize threading |
| 257 | */ | 262 | */ |
| 258 | void ThreadingInit(); | 263 | void ThreadingInit(); |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index ef25acc4a..5839d7230 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -584,7 +584,7 @@ static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point | |||
| 584 | static void ExitThread() { | 584 | static void ExitThread() { |
| 585 | LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); | 585 | LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); |
| 586 | 586 | ||
| 587 | Kernel::GetCurrentThread()->Stop(); | 587 | Kernel::ExitCurrentThread(); |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | /// Gets the priority for the specified thread | 590 | /// Gets the priority for the specified thread |