Fixed the codestyle to match our clang-format rules.
This commit is contained in:
parent
406907d570
commit
5b1edc6ae7
@ -230,7 +230,8 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
|
|||||||
list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
|
list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
|
||||||
}
|
}
|
||||||
if (thread.status == THREADSTATUS_WAIT_SYNCH) {
|
if (thread.status == THREADSTATUS_WAIT_SYNCH) {
|
||||||
list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, thread.IsSleepingOnWaitAll()));
|
list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects,
|
||||||
|
thread.IsSleepingOnWaitAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -50,9 +50,9 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
|
|||||||
if (thread->current_priority >= candidate_priority)
|
if (thread->current_priority >= candidate_priority)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), [](const SharedPtr<WaitObject>& object) {
|
bool ready_to_run =
|
||||||
return object->ShouldWait();
|
std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
|
||||||
});
|
[](const SharedPtr<WaitObject>& object) { return object->ShouldWait(); });
|
||||||
if (ready_to_run) {
|
if (ready_to_run) {
|
||||||
candidate = thread.get();
|
candidate = thread.get();
|
||||||
candidate_priority = thread->current_priority;
|
candidate_priority = thread->current_priority;
|
||||||
@ -83,7 +83,8 @@ void WaitObject::WakeupAllWaitingThreads() {
|
|||||||
|
|
||||||
thread->SetWaitSynchronizationResult(RESULT_SUCCESS);
|
thread->SetWaitSynchronizationResult(RESULT_SUCCESS);
|
||||||
thread->ResumeFromWait();
|
thread->ResumeFromWait();
|
||||||
// Note: Removing the thread from the object's waitlist will be done by GetHighestPriorityReadyThread
|
// Note: Removing the thread from the object's waitlist will be
|
||||||
|
// done by GetHighestPriorityReadyThread.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,17 +178,19 @@ public:
|
|||||||
/// Mutexes currently held by this thread, which will be released when it exits.
|
/// Mutexes currently held by this thread, which will be released when it exits.
|
||||||
boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
|
boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
|
||||||
|
|
||||||
SharedPtr<Process> owner_process; ///< Process that owns this thread
|
SharedPtr<Process> owner_process; ///< Process that owns this thread
|
||||||
|
|
||||||
/// Objects that the thread is waiting on.
|
/// Objects that the thread is waiting on.
|
||||||
/// This is only populated when the thread should wait for all the objects to become ready.
|
/// This is only populated when the thread should wait for all the objects to become ready.
|
||||||
std::vector<SharedPtr<WaitObject>> wait_objects;
|
std::vector<SharedPtr<WaitObject>> wait_objects;
|
||||||
|
|
||||||
boost::container::flat_map<int, s32> wait_objects_index; ///< Mapping of Object ids to their position in the last waitlist that this object waited on.
|
/// Mapping of Object ids to their position in the last waitlist that this object waited on.
|
||||||
|
boost::container::flat_map<int, s32> wait_objects_index;
|
||||||
|
|
||||||
VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
|
VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
|
||||||
|
|
||||||
bool wait_set_output; ///< True if the WaitSynchronizationN output parameter should be set on thread wakeup
|
/// True if the WaitSynchronizationN output parameter should be set on thread wakeup.
|
||||||
|
bool wait_set_output;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
|
@ -264,14 +264,16 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
|
|||||||
return ERR_SYNC_TIMEOUT;
|
return ERR_SYNC_TIMEOUT;
|
||||||
|
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
// TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
|
// TODO(Subv): Perform things like update the mutex lock owner's priority to
|
||||||
// Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
|
// 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;
|
thread->status = THREADSTATUS_WAIT_SYNCH;
|
||||||
|
|
||||||
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
||||||
thread->WakeAfterDelay(nano_seconds);
|
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.
|
// Otherwise we retain the default value of timeout.
|
||||||
return ERR_SYNC_TIMEOUT;
|
return ERR_SYNC_TIMEOUT;
|
||||||
}
|
}
|
||||||
@ -316,20 +318,22 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
|
|||||||
thread->wait_objects_index.clear();
|
thread->wait_objects_index.clear();
|
||||||
|
|
||||||
if (wait_all) {
|
if (wait_all) {
|
||||||
bool all_available = std::all_of(objects.begin(), objects.end(), [](const ObjectPtr& object) {
|
bool all_available =
|
||||||
return !object->ShouldWait();
|
std::all_of(objects.begin(), objects.end(),
|
||||||
});
|
[](const ObjectPtr& object) { return !object->ShouldWait(); });
|
||||||
if (all_available) {
|
if (all_available) {
|
||||||
// We can acquire all objects right now, do so.
|
// We can acquire all objects right now, do so.
|
||||||
for (auto& object : objects)
|
for (auto& object : objects)
|
||||||
object->Acquire();
|
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;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not all objects were available right now, prepare to suspend the thread.
|
// 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)
|
if (nano_seconds == 0)
|
||||||
return ERR_SYNC_TIMEOUT;
|
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.
|
// Add the thread to each of the objects' waiting threads.
|
||||||
for (auto& object : objects) {
|
for (auto& object : objects) {
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
// TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
|
// TODO(Subv): Perform things like update the mutex lock owner's priority to
|
||||||
// Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
|
// 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
|
// 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.
|
// This value gets set to -1 by default in this case, it is not modified after this.
|
||||||
*out = -1;
|
*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;
|
return ERR_SYNC_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
// Find the first object that is acquirable in the provided list of objects
|
// 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) {
|
auto itr = std::find_if(objects.begin(), objects.end(),
|
||||||
return !object->ShouldWait();
|
[](const ObjectPtr& object) { return !object->ShouldWait(); });
|
||||||
});
|
|
||||||
|
|
||||||
if (itr != objects.end()) {
|
if (itr != objects.end()) {
|
||||||
// We found a ready object, acquire it and set the result value
|
// 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.
|
// 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)
|
if (nano_seconds == 0)
|
||||||
return ERR_SYNC_TIMEOUT;
|
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.
|
// 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);
|
thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i);
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
// TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion.
|
// TODO(Subv): Perform things like update the mutex lock owner's priority to
|
||||||
// Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here.
|
// 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
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
||||||
thread->WakeAfterDelay(nano_seconds);
|
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
|
// Otherwise we retain the default value of timeout, and -1 in the out parameter
|
||||||
thread->wait_set_output = true;
|
thread->wait_set_output = true;
|
||||||
*out = -1;
|
*out = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user