diff options
| author | 2019-04-02 09:22:53 -0400 | |
|---|---|---|
| committer | 2019-10-15 11:55:12 -0400 | |
| commit | fcc6b34fff3c9322a35e6457a699e70585a7e014 (patch) | |
| tree | 7fbd96994170ff2707f65e42dc6a4832c6531d07 /src/core/hle/kernel/svc.cpp | |
| parent | Comment and reorganize the scheduler (diff) | |
| download | yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.gz yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.xz yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.zip | |
Correct PrepareReschedule
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index ee1e9f006..560ac3945 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -516,7 +516,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr | |||
| 516 | thread->WakeAfterDelay(nano_seconds); | 516 | thread->WakeAfterDelay(nano_seconds); |
| 517 | thread->SetWakeupCallback(DefaultThreadWakeupCallback); | 517 | thread->SetWakeupCallback(DefaultThreadWakeupCallback); |
| 518 | 518 | ||
| 519 | system.CpuCore(thread->GetProcessorID()).PrepareReschedule(); | 519 | system.PrepareReschedule(thread->GetProcessorID()); |
| 520 | 520 | ||
| 521 | return RESULT_TIMEOUT; | 521 | return RESULT_TIMEOUT; |
| 522 | } | 522 | } |
| @@ -534,8 +534,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand | |||
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | thread->CancelWait(); | 536 | thread->CancelWait(); |
| 537 | if (thread->GetProcessorID() >= 0) | 537 | system.PrepareReschedule(thread->GetProcessorID()); |
| 538 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 539 | return RESULT_SUCCESS; | 538 | return RESULT_SUCCESS; |
| 540 | } | 539 | } |
| 541 | 540 | ||
| @@ -1069,8 +1068,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act | |||
| 1069 | 1068 | ||
| 1070 | thread->SetActivity(static_cast<ThreadActivity>(activity)); | 1069 | thread->SetActivity(static_cast<ThreadActivity>(activity)); |
| 1071 | 1070 | ||
| 1072 | if (thread->GetProcessorID() >= 0) | 1071 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1073 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1074 | return RESULT_SUCCESS; | 1072 | return RESULT_SUCCESS; |
| 1075 | } | 1073 | } |
| 1076 | 1074 | ||
| @@ -1152,8 +1150,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri | |||
| 1152 | 1150 | ||
| 1153 | thread->SetPriority(priority); | 1151 | thread->SetPriority(priority); |
| 1154 | 1152 | ||
| 1155 | if (thread->GetProcessorID() >= 0) | 1153 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1156 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1157 | return RESULT_SUCCESS; | 1154 | return RESULT_SUCCESS; |
| 1158 | } | 1155 | } |
| 1159 | 1156 | ||
| @@ -1509,8 +1506,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1509 | thread->SetName( | 1506 | thread->SetName( |
| 1510 | fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); | 1507 | fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); |
| 1511 | 1508 | ||
| 1512 | if (thread->GetProcessorID() >= 0) | 1509 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1513 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1514 | 1510 | ||
| 1515 | return RESULT_SUCCESS; | 1511 | return RESULT_SUCCESS; |
| 1516 | } | 1512 | } |
| @@ -1532,10 +1528,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1532 | thread->ResumeFromWait(); | 1528 | thread->ResumeFromWait(); |
| 1533 | 1529 | ||
| 1534 | if (thread->GetStatus() == ThreadStatus::Ready) { | 1530 | if (thread->GetStatus() == ThreadStatus::Ready) { |
| 1535 | if (thread->GetProcessorID() >= 0) | 1531 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1536 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1537 | else | ||
| 1538 | Core::System::GetInstance().GlobalScheduler().SetReselectionPending(); | ||
| 1539 | } | 1532 | } |
| 1540 | 1533 | ||
| 1541 | return RESULT_SUCCESS; | 1534 | return RESULT_SUCCESS; |
| @@ -1582,10 +1575,7 @@ static void SleepThread(Core::System& system, s64 nanoseconds) { | |||
| 1582 | current_thread->Sleep(nanoseconds); | 1575 | current_thread->Sleep(nanoseconds); |
| 1583 | } | 1576 | } |
| 1584 | 1577 | ||
| 1585 | // Reschedule all CPU cores | 1578 | system.PrepareReschedule(current_thread->GetProcessorID()); |
| 1586 | for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) { | ||
| 1587 | system.CpuCore(i).PrepareReschedule(); | ||
| 1588 | } | ||
| 1589 | } | 1579 | } |
| 1590 | 1580 | ||
| 1591 | /// Wait process wide key atomic | 1581 | /// Wait process wide key atomic |
| @@ -1632,7 +1622,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add | |||
| 1632 | 1622 | ||
| 1633 | // Note: Deliberately don't attempt to inherit the lock owner's priority. | 1623 | // Note: Deliberately don't attempt to inherit the lock owner's priority. |
| 1634 | 1624 | ||
| 1635 | system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule(); | 1625 | system.PrepareReschedule(current_thread->GetProcessorID()); |
| 1636 | return RESULT_SUCCESS; | 1626 | return RESULT_SUCCESS; |
| 1637 | } | 1627 | } |
| 1638 | 1628 | ||
| @@ -1644,7 +1634,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var | |||
| 1644 | 1634 | ||
| 1645 | // Retrieve a list of all threads that are waiting for this condition variable. | 1635 | // Retrieve a list of all threads that are waiting for this condition variable. |
| 1646 | std::vector<SharedPtr<Thread>> waiting_threads; | 1636 | std::vector<SharedPtr<Thread>> waiting_threads; |
| 1647 | const auto& scheduler = Core::System::GetInstance().GlobalScheduler(); | 1637 | const auto& scheduler = system.GlobalScheduler(); |
| 1648 | const auto& thread_list = scheduler.GetThreadList(); | 1638 | const auto& thread_list = scheduler.GetThreadList(); |
| 1649 | 1639 | ||
| 1650 | for (const auto& thread : thread_list) { | 1640 | for (const auto& thread : thread_list) { |
| @@ -1706,8 +1696,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var | |||
| 1706 | thread->SetLockOwner(nullptr); | 1696 | thread->SetLockOwner(nullptr); |
| 1707 | thread->SetMutexWaitAddress(0); | 1697 | thread->SetMutexWaitAddress(0); |
| 1708 | thread->SetWaitHandle(0); | 1698 | thread->SetWaitHandle(0); |
| 1709 | if (thread->GetProcessorID() >= 0) | 1699 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1710 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1711 | } else { | 1700 | } else { |
| 1712 | // Atomically signal that the mutex now has a waiting thread. | 1701 | // Atomically signal that the mutex now has a waiting thread. |
| 1713 | do { | 1702 | do { |
| @@ -1731,8 +1720,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var | |||
| 1731 | thread->SetStatus(ThreadStatus::WaitMutex); | 1720 | thread->SetStatus(ThreadStatus::WaitMutex); |
| 1732 | 1721 | ||
| 1733 | owner->AddMutexWaiter(thread); | 1722 | owner->AddMutexWaiter(thread); |
| 1734 | if (thread->GetProcessorID() >= 0) | 1723 | system.PrepareReschedule(thread->GetProcessorID()); |
| 1735 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 1736 | } | 1724 | } |
| 1737 | } | 1725 | } |
| 1738 | 1726 | ||
| @@ -1758,13 +1746,10 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, | |||
| 1758 | } | 1746 | } |
| 1759 | 1747 | ||
| 1760 | const auto arbitration_type = static_cast<AddressArbiter::ArbitrationType>(type); | 1748 | const auto arbitration_type = static_cast<AddressArbiter::ArbitrationType>(type); |
| 1761 | auto& address_arbiter = | 1749 | auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter(); |
| 1762 | system.Kernel().CurrentProcess()->GetAddressArbiter(); | ||
| 1763 | ResultCode result = address_arbiter.WaitForAddress(address, arbitration_type, value, timeout); | 1750 | ResultCode result = address_arbiter.WaitForAddress(address, arbitration_type, value, timeout); |
| 1764 | if (result == RESULT_SUCCESS) | 1751 | if (result == RESULT_SUCCESS) |
| 1765 | Core::System::GetInstance() | 1752 | system.PrepareReschedule(); |
| 1766 | .CpuCore(GetCurrentThread()->GetProcessorID()) | ||
| 1767 | .PrepareReschedule(); | ||
| 1768 | return result; | 1753 | return result; |
| 1769 | } | 1754 | } |
| 1770 | 1755 | ||
| @@ -2051,10 +2036,10 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2051 | return ERR_INVALID_HANDLE; | 2036 | return ERR_INVALID_HANDLE; |
| 2052 | } | 2037 | } |
| 2053 | 2038 | ||
| 2054 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | 2039 | system.PrepareReschedule(thread->GetProcessorID()); |
| 2055 | thread->ChangeCore(core, affinity_mask); | 2040 | thread->ChangeCore(core, affinity_mask); |
| 2056 | if (thread->GetProcessorID() >= 0) | 2041 | system.PrepareReschedule(thread->GetProcessorID()); |
| 2057 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | 2042 | |
| 2058 | return RESULT_SUCCESS; | 2043 | return RESULT_SUCCESS; |
| 2059 | } | 2044 | } |
| 2060 | 2045 | ||
| @@ -2165,7 +2150,7 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) { | |||
| 2165 | } | 2150 | } |
| 2166 | 2151 | ||
| 2167 | writable_event->Signal(); | 2152 | writable_event->Signal(); |
| 2168 | Core::System::GetInstance().PrepareReschedule(); | 2153 | system.PrepareReschedule(); |
| 2169 | return RESULT_SUCCESS; | 2154 | return RESULT_SUCCESS; |
| 2170 | } | 2155 | } |
| 2171 | 2156 | ||