summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/mutex.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 663d0f4b6..8493d0f78 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -22,10 +22,10 @@ namespace Kernel {
/// Returns the number of threads that are waiting for a mutex, and the highest priority one among
/// those.
-static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread(
- const SharedPtr<Thread>& current_thread, VAddr mutex_addr) {
+static std::pair<std::shared_ptr<Thread>, u32> GetHighestPriorityMutexWaitingThread(
+ const std::shared_ptr<Thread>& current_thread, VAddr mutex_addr) {
- SharedPtr<Thread> highest_priority_thread;
+ std::shared_ptr<Thread> highest_priority_thread;
u32 num_waiters = 0;
for (const auto& thread : current_thread->GetMutexWaitingThreads()) {
@@ -45,14 +45,14 @@ static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread(
}
/// Update the mutex owner field of all threads waiting on the mutex to point to the new owner.
-static void TransferMutexOwnership(VAddr mutex_addr, SharedPtr<Thread> current_thread,
- SharedPtr<Thread> new_owner) {
+static void TransferMutexOwnership(VAddr mutex_addr, std::shared_ptr<Thread> current_thread,
+ std::shared_ptr<Thread> new_owner) {
const auto threads = current_thread->GetMutexWaitingThreads();
for (const auto& thread : threads) {
if (thread->GetMutexWaitAddress() != mutex_addr)
continue;
- ASSERT(thread->GetLockOwner() == current_thread);
+ ASSERT(thread->GetLockOwner() == current_thread.get());
current_thread->RemoveMutexWaiter(thread);
if (new_owner != thread)
new_owner->AddMutexWaiter(thread);
@@ -70,9 +70,10 @@ ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle,
}
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
- Thread* const current_thread = system.CurrentScheduler().GetCurrentThread();
- SharedPtr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle);
- SharedPtr<Thread> requesting_thread = handle_table.Get<Thread>(requesting_thread_handle);
+ std::shared_ptr<Thread> current_thread =
+ SharedFrom(system.CurrentScheduler().GetCurrentThread());
+ std::shared_ptr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle);
+ std::shared_ptr<Thread> requesting_thread = handle_table.Get<Thread>(requesting_thread_handle);
// TODO(Subv): It is currently unknown if it is possible to lock a mutex in behalf of another
// thread.
@@ -110,7 +111,8 @@ ResultCode Mutex::Release(VAddr address) {
return ERR_INVALID_ADDRESS;
}
- auto* const current_thread = system.CurrentScheduler().GetCurrentThread();
+ std::shared_ptr<Thread> current_thread =
+ SharedFrom(system.CurrentScheduler().GetCurrentThread());
auto [thread, num_waiters] = GetHighestPriorityMutexWaitingThread(current_thread, address);
// There are no more threads waiting for the mutex, release it completely.