diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 3 |
4 files changed, 21 insertions, 8 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 3bb843aab..cabab744a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -51,7 +51,7 @@ void RunLoop(int tight_loop) { | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | HW::Update(); | 53 | HW::Update(); |
| 54 | if (HLE::g_reschedule) { | 54 | if (HLE::IsReschedulePending()) { |
| 55 | Kernel::Reschedule(); | 55 | Kernel::Reschedule(); |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index e545de3b5..5c5373517 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -12,9 +12,13 @@ | |||
| 12 | 12 | ||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 14 | 14 | ||
| 15 | namespace HLE { | 15 | namespace { |
| 16 | |||
| 17 | bool reschedule; ///< If true, immediately reschedules the CPU to a new thread | ||
| 16 | 18 | ||
| 17 | bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread | 19 | } |
| 20 | |||
| 21 | namespace HLE { | ||
| 18 | 22 | ||
| 19 | void Reschedule(const char *reason) { | 23 | void Reschedule(const char *reason) { |
| 20 | DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); | 24 | DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); |
| @@ -27,13 +31,21 @@ void Reschedule(const char *reason) { | |||
| 27 | 31 | ||
| 28 | Core::g_app_core->PrepareReschedule(); | 32 | Core::g_app_core->PrepareReschedule(); |
| 29 | 33 | ||
| 30 | g_reschedule = true; | 34 | reschedule = true; |
| 35 | } | ||
| 36 | |||
| 37 | bool IsReschedulePending() { | ||
| 38 | return reschedule; | ||
| 39 | } | ||
| 40 | |||
| 41 | void DoneRescheduling() { | ||
| 42 | reschedule = false; | ||
| 31 | } | 43 | } |
| 32 | 44 | ||
| 33 | void Init() { | 45 | void Init() { |
| 34 | Service::Init(); | 46 | Service::Init(); |
| 35 | 47 | ||
| 36 | g_reschedule = false; | 48 | reschedule = false; |
| 37 | 49 | ||
| 38 | LOG_DEBUG(Kernel, "initialized OK"); | 50 | LOG_DEBUG(Kernel, "initialized OK"); |
| 39 | } | 51 | } |
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index e0b97797c..69ac0ade6 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h | |||
| @@ -13,9 +13,9 @@ const Handle INVALID_HANDLE = 0; | |||
| 13 | 13 | ||
| 14 | namespace HLE { | 14 | namespace HLE { |
| 15 | 15 | ||
| 16 | extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread | ||
| 17 | |||
| 18 | void Reschedule(const char *reason); | 16 | void Reschedule(const char *reason); |
| 17 | bool IsReschedulePending(); | ||
| 18 | void DoneRescheduling(); | ||
| 19 | 19 | ||
| 20 | void Init(); | 20 | void Init(); |
| 21 | void Shutdown(); | 21 | void Shutdown(); |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index bf32f653d..6dc95d0f1 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -483,7 +483,8 @@ void Reschedule() { | |||
| 483 | 483 | ||
| 484 | Thread* cur = GetCurrentThread(); | 484 | Thread* cur = GetCurrentThread(); |
| 485 | Thread* next = PopNextReadyThread(); | 485 | Thread* next = PopNextReadyThread(); |
| 486 | HLE::g_reschedule = false; | 486 | |
| 487 | HLE::DoneRescheduling(); | ||
| 487 | 488 | ||
| 488 | // Don't bother switching to the same thread | 489 | // Don't bother switching to the same thread |
| 489 | if (next == cur) | 490 | if (next == cur) |