summaryrefslogtreecommitdiffstats
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2016-12-14 18:13:02 +0100
committerSubv <subv2112@gmail.com>2016-12-14 18:35:01 +0100
commit5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2 (patch)
treeb6fbcc194effc5e05a608ebde0ea3c887720d920 /src/core/hle/svc.cpp
parentProperly remove a thread from its wait_objects' waitlist when it is awoken by a timeout. (diff)
downloadyuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.gz
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.bz2
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.lz
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.xz
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.zst
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.zip
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index c81c14443..a4a00d9b2 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -264,14 +264,16 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
return ERR_SYNC_TIMEOUT;
object->AddWaitingThread(thread);
- // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
- // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
+ // TODO(Subv): Perform things like update the mutex lock owner's priority to
+ // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
+ // but it should be moved to a function that is called from here.
thread->status = THREADSTATUS_WAIT_SYNCH;
// Create an event to wake the thread up after the specified nanosecond delay has passed
thread->WakeAfterDelay(nano_seconds);
- // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in its wait objects.
+ // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread
+ // resumes due to a signal in its wait objects.
// Otherwise we retain the default value of timeout.
return ERR_SYNC_TIMEOUT;
}
@@ -316,20 +318,22 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
thread->wait_objects_index.clear();
if (wait_all) {
- bool all_available = std::all_of(objects.begin(), objects.end(), [](const ObjectPtr& object) {
- return !object->ShouldWait();
- });
+ bool all_available =
+ std::all_of(objects.begin(), objects.end(),
+ [](const ObjectPtr& object) { return !object->ShouldWait(); });
if (all_available) {
// We can acquire all objects right now, do so.
for (auto& object : objects)
object->Acquire();
- // Note: In this case, the `out` parameter is not set, and retains whatever value it had before.
+ // Note: In this case, the `out` parameter is not set,
+ // and retains whatever value it had before.
return RESULT_SUCCESS;
}
// Not all objects were available right now, prepare to suspend the thread.
- // If a timeout value of 0 was provided, just return the Timeout error code instead of suspending the thread.
+ // If a timeout value of 0 was provided, just return the Timeout error code instead of
+ // suspending the thread.
if (nano_seconds == 0)
return ERR_SYNC_TIMEOUT;
@@ -339,8 +343,9 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// Add the thread to each of the objects' waiting threads.
for (auto& object : objects) {
object->AddWaitingThread(thread);
- // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
- // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
+ // TODO(Subv): Perform things like update the mutex lock owner's priority to
+ // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
+ // but it should be moved to a function that is called from here.
}
// Set the thread's waitlist to the list of objects passed to WaitSynchronizationN
@@ -351,13 +356,13 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// This value gets set to -1 by default in this case, it is not modified after this.
*out = -1;
- // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in one of its wait objects.
+ // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to
+ // a signal in one of its wait objects.
return ERR_SYNC_TIMEOUT;
} else {
// Find the first object that is acquirable in the provided list of objects
- auto itr = std::find_if(objects.begin(), objects.end(), [](const ObjectPtr& object) {
- return !object->ShouldWait();
- });
+ auto itr = std::find_if(objects.begin(), objects.end(),
+ [](const ObjectPtr& object) { return !object->ShouldWait(); });
if (itr != objects.end()) {
// We found a ready object, acquire it and set the result value
@@ -369,7 +374,8 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// No objects were ready to be acquired, prepare to suspend the thread.
- // If a timeout value of 0 was provided, just return the Timeout error code instead of suspending the thread.
+ // If a timeout value of 0 was provided, just return the Timeout error code instead of
+ // suspending the thread.
if (nano_seconds == 0)
return ERR_SYNC_TIMEOUT;
@@ -385,16 +391,19 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
// Set the index of this object in the mapping of Objects -> index for this thread.
thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i);
object->AddWaitingThread(thread);
- // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
- // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
+ // TODO(Subv): Perform things like update the mutex lock owner's priority to
+ // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
+ // but it should be moved to a function that is called from here.
}
- // Note: If no handles and no timeout were given, then the thread will deadlock, this is consistent with hardware behavior.
+ // Note: If no handles and no timeout were given, then the thread will deadlock, this is
+ // consistent with hardware behavior.
// Create an event to wake the thread up after the specified nanosecond delay has passed
thread->WakeAfterDelay(nano_seconds);
- // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in one of its wait objects.
+ // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a
+ // signal in one of its wait objects.
// Otherwise we retain the default value of timeout, and -1 in the out parameter
thread->wait_set_output = true;
*out = -1;