From 10447d1f4831b495d7bef7711681ddd548f847a6 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 21:42:50 -0400 Subject: kernel: changed main thread priority to default, updated Kernel::Reschedule to use PrepareReschedule --- src/core/hle/hle.cpp | 5 +++-- src/core/hle/hle.h | 2 +- src/core/hle/kernel/kernel.cpp | 3 ++- src/core/hle/kernel/kernel.h | 1 + src/core/hle/kernel/thread.cpp | 6 +++--- src/core/hle/svc.cpp | 9 +++++++-- 6 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index f703da44..08b0685c 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -7,6 +7,7 @@ #include "core/mem_map.h" #include "core/hle/hle.h" #include "core/hle/svc.h" +#include "core/hle/kernel/thread.h" #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -41,11 +42,11 @@ void EatCycles(u32 cycles) { // TODO: ImplementMe } -void ReSchedule(const char *reason) { +void Reschedule(const char *reason) { #ifdef _DEBUG _dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); #endif - // TODO: ImplementMe + Core::g_app_core->PrepareReschedule(); } void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index c31e273b..9bc4bfd2 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h @@ -37,7 +37,7 @@ void CallSVC(u32 opcode); void EatCycles(u32 cycles); -void ReSchedule(const char *reason); +void Reschedule(const char *reason); void Init(); diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index de80de89..c0c0fa17 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -14,6 +14,7 @@ namespace Kernel { +Handle g_main_thread = 0; ObjectPool g_object_pool; ObjectPool::ObjectPool() { @@ -150,7 +151,7 @@ bool LoadExec(u32 entry_point) { Core::g_app_core->SetPC(entry_point); // 0x30 is the typical main thread priority I've seen used so far - Handle thread = Kernel::SetupMainThread(0x30); + g_main_thread = Kernel::SetupMainThread(THREADPRIO_DEFAULT); return true; } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 620cd2d7..2192df16 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -163,6 +163,7 @@ private: }; extern ObjectPool g_object_pool; +extern Handle g_main_thread; /** * Loads executable stored at specified address diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index d1e13c94..f2094f7a 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -285,11 +285,11 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3 HLE::EatCycles(32000); + CallThread(t); + // This won't schedule to the new thread, but it may to one woken from eating cycles. // Technically, this should not eat all at once, and reschedule in the middle, but that's hard. - HLE::ReSchedule("thread created"); - - CallThread(t); + //HLE::Reschedule("thread created"); return handle; } diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 11b77e2c..0c2412a6 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -125,8 +125,11 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { Result res = object->WaitSynchronization(&wait); if (wait) { + // Set current thread to wait state if handle was not unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - Kernel::Reschedule(); + + // Check for next thread to schedule + HLE::Reschedule(__func__); // Context switch - Function blocked, is not actually returning (will be "called" again) @@ -178,7 +181,9 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa // Set current thread to wait state if not all handles were unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - Kernel::Reschedule(); + + // Check for next thread to schedule + HLE::Reschedule(__func__); // Context switch - Function blocked, is not actually returning (will be "called" again) -- cgit v1.2.3