diff options
| author | 2018-10-05 13:41:54 -0400 | |
|---|---|---|
| committer | 2018-10-05 13:41:54 -0400 | |
| commit | e51d715700a35a8f14e5b804b6f7553c9a40888b (patch) | |
| tree | 96917effcab47b089718a90851b2b203717d324a /src/core/hle/kernel/mutex.cpp | |
| parent | Merge pull request #1442 from lioncash/format (diff) | |
| parent | kernel/thread: Make all instance variables private (diff) | |
| download | yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.gz yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.xz yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.zip | |
Merge pull request #1439 from lioncash/thread
kernel/thread: Make all instance variables private
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 81675eac5..78d8b74bb 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -28,11 +28,11 @@ static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread( | |||
| 28 | SharedPtr<Thread> highest_priority_thread; | 28 | SharedPtr<Thread> highest_priority_thread; |
| 29 | u32 num_waiters = 0; | 29 | u32 num_waiters = 0; |
| 30 | 30 | ||
| 31 | for (auto& thread : current_thread->wait_mutex_threads) { | 31 | for (const auto& thread : current_thread->GetMutexWaitingThreads()) { |
| 32 | if (thread->mutex_wait_address != mutex_addr) | 32 | if (thread->GetMutexWaitAddress() != mutex_addr) |
| 33 | continue; | 33 | continue; |
| 34 | 34 | ||
| 35 | ASSERT(thread->status == ThreadStatus::WaitMutex); | 35 | ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex); |
| 36 | 36 | ||
| 37 | ++num_waiters; | 37 | ++num_waiters; |
| 38 | if (highest_priority_thread == nullptr || | 38 | if (highest_priority_thread == nullptr || |
| @@ -47,12 +47,12 @@ static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread( | |||
| 47 | /// Update the mutex owner field of all threads waiting on the mutex to point to the new owner. | 47 | /// Update the mutex owner field of all threads waiting on the mutex to point to the new owner. |
| 48 | static void TransferMutexOwnership(VAddr mutex_addr, SharedPtr<Thread> current_thread, | 48 | static void TransferMutexOwnership(VAddr mutex_addr, SharedPtr<Thread> current_thread, |
| 49 | SharedPtr<Thread> new_owner) { | 49 | SharedPtr<Thread> new_owner) { |
| 50 | auto threads = current_thread->wait_mutex_threads; | 50 | const auto& threads = current_thread->GetMutexWaitingThreads(); |
| 51 | for (auto& thread : threads) { | 51 | for (const auto& thread : threads) { |
| 52 | if (thread->mutex_wait_address != mutex_addr) | 52 | if (thread->GetMutexWaitAddress() != mutex_addr) |
| 53 | continue; | 53 | continue; |
| 54 | 54 | ||
| 55 | ASSERT(thread->lock_owner == current_thread); | 55 | ASSERT(thread->GetLockOwner() == current_thread); |
| 56 | current_thread->RemoveMutexWaiter(thread); | 56 | current_thread->RemoveMutexWaiter(thread); |
| 57 | if (new_owner != thread) | 57 | if (new_owner != thread) |
| 58 | new_owner->AddMutexWaiter(thread); | 58 | new_owner->AddMutexWaiter(thread); |
| @@ -84,11 +84,11 @@ ResultCode Mutex::TryAcquire(HandleTable& handle_table, VAddr address, Handle ho | |||
| 84 | return ERR_INVALID_HANDLE; | 84 | return ERR_INVALID_HANDLE; |
| 85 | 85 | ||
| 86 | // Wait until the mutex is released | 86 | // Wait until the mutex is released |
| 87 | GetCurrentThread()->mutex_wait_address = address; | 87 | GetCurrentThread()->SetMutexWaitAddress(address); |
| 88 | GetCurrentThread()->wait_handle = requesting_thread_handle; | 88 | GetCurrentThread()->SetWaitHandle(requesting_thread_handle); |
| 89 | 89 | ||
| 90 | GetCurrentThread()->status = ThreadStatus::WaitMutex; | 90 | GetCurrentThread()->SetStatus(ThreadStatus::WaitMutex); |
| 91 | GetCurrentThread()->wakeup_callback = nullptr; | 91 | GetCurrentThread()->InvalidateWakeupCallback(); |
| 92 | 92 | ||
| 93 | // Update the lock holder thread's priority to prevent priority inversion. | 93 | // Update the lock holder thread's priority to prevent priority inversion. |
| 94 | holding_thread->AddMutexWaiter(GetCurrentThread()); | 94 | holding_thread->AddMutexWaiter(GetCurrentThread()); |
| @@ -115,7 +115,7 @@ ResultCode Mutex::Release(VAddr address) { | |||
| 115 | // Transfer the ownership of the mutex from the previous owner to the new one. | 115 | // Transfer the ownership of the mutex from the previous owner to the new one. |
| 116 | TransferMutexOwnership(address, GetCurrentThread(), thread); | 116 | TransferMutexOwnership(address, GetCurrentThread(), thread); |
| 117 | 117 | ||
| 118 | u32 mutex_value = thread->wait_handle; | 118 | u32 mutex_value = thread->GetWaitHandle(); |
| 119 | 119 | ||
| 120 | if (num_waiters >= 2) { | 120 | if (num_waiters >= 2) { |
| 121 | // Notify the guest that there are still some threads waiting for the mutex | 121 | // Notify the guest that there are still some threads waiting for the mutex |
| @@ -125,13 +125,13 @@ ResultCode Mutex::Release(VAddr address) { | |||
| 125 | // Grant the mutex to the next waiting thread and resume it. | 125 | // Grant the mutex to the next waiting thread and resume it. |
| 126 | Memory::Write32(address, mutex_value); | 126 | Memory::Write32(address, mutex_value); |
| 127 | 127 | ||
| 128 | ASSERT(thread->status == ThreadStatus::WaitMutex); | 128 | ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex); |
| 129 | thread->ResumeFromWait(); | 129 | thread->ResumeFromWait(); |
| 130 | 130 | ||
| 131 | thread->lock_owner = nullptr; | 131 | thread->SetLockOwner(nullptr); |
| 132 | thread->condvar_wait_address = 0; | 132 | thread->SetCondVarWaitAddress(0); |
| 133 | thread->mutex_wait_address = 0; | 133 | thread->SetMutexWaitAddress(0); |
| 134 | thread->wait_handle = 0; | 134 | thread->SetWaitHandle(0); |
| 135 | 135 | ||
| 136 | return RESULT_SUCCESS; | 136 | return RESULT_SUCCESS; |
| 137 | } | 137 | } |