mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-29 13:14:14 +01:00
Rename KThread::waitKey
to KThread::waitMutex
It was determined that `waitKey` is too ambiguous when waiter members are used for both mutexes and condition variables.
This commit is contained in:
parent
91bb8d231a
commit
5694c9b34b
@ -139,7 +139,7 @@ namespace skyline::kernel::type {
|
|||||||
state.scheduler->RemoveThread();
|
state.scheduler->RemoveThread();
|
||||||
|
|
||||||
thread->waitThread = owner;
|
thread->waitThread = owner;
|
||||||
thread->waitKey = mutex;
|
thread->waitMutex = mutex;
|
||||||
thread->waitTag = tag;
|
thread->waitTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,18 +158,18 @@ namespace skyline::kernel::type {
|
|||||||
|
|
||||||
std::scoped_lock lock{state.thread->waiterMutex};
|
std::scoped_lock lock{state.thread->waiterMutex};
|
||||||
auto &waiters{state.thread->waiters};
|
auto &waiters{state.thread->waiters};
|
||||||
auto nextOwnerIt{std::find_if(waiters.begin(), waiters.end(), [mutex](const std::shared_ptr<KThread> &thread) { return thread->waitKey == mutex; })};
|
auto nextOwnerIt{std::find_if(waiters.begin(), waiters.end(), [mutex](const std::shared_ptr<KThread> &thread) { return thread->waitMutex == mutex; })};
|
||||||
if (nextOwnerIt != waiters.end()) {
|
if (nextOwnerIt != waiters.end()) {
|
||||||
auto nextOwner{*nextOwnerIt};
|
auto nextOwner{*nextOwnerIt};
|
||||||
std::scoped_lock nextLock{nextOwner->waiterMutex};
|
std::scoped_lock nextLock{nextOwner->waiterMutex};
|
||||||
nextOwner->waitThread = std::shared_ptr<KThread>{nullptr};
|
nextOwner->waitThread = std::shared_ptr<KThread>{nullptr};
|
||||||
nextOwner->waitKey = nullptr;
|
nextOwner->waitMutex = nullptr;
|
||||||
|
|
||||||
// Move all threads waiting on this key to the next owner's waiter list
|
// Move all threads waiting on this key to the next owner's waiter list
|
||||||
std::shared_ptr<KThread> nextWaiter{};
|
std::shared_ptr<KThread> nextWaiter{};
|
||||||
for (auto it{waiters.erase(nextOwnerIt)}, nextIt{std::next(it)}; it != waiters.end(); it = nextIt++) {
|
for (auto it{waiters.erase(nextOwnerIt)}, nextIt{std::next(it)}; it != waiters.end(); it = nextIt++) {
|
||||||
auto thread{*it};
|
auto thread{*it};
|
||||||
if (thread->waitKey == mutex) {
|
if (thread->waitMutex == mutex) {
|
||||||
nextOwner->waiters.splice(std::upper_bound(nextOwner->waiters.begin(), nextOwner->waiters.end(), (*it)->priority.load(), KThread::IsHigherPriority), waiters, it);
|
nextOwner->waiters.splice(std::upper_bound(nextOwner->waiters.begin(), nextOwner->waiters.end(), (*it)->priority.load(), KThread::IsHigherPriority), waiters, it);
|
||||||
thread->waitThread = nextOwner;
|
thread->waitThread = nextOwner;
|
||||||
if (!nextWaiter)
|
if (!nextWaiter)
|
||||||
@ -221,7 +221,7 @@ namespace skyline::kernel::type {
|
|||||||
{
|
{
|
||||||
// Update all waiter information
|
// Update all waiter information
|
||||||
std::unique_lock lock{state.thread->waiterMutex};
|
std::unique_lock lock{state.thread->waiterMutex};
|
||||||
state.thread->waitKey = mutex;
|
state.thread->waitMutex = mutex;
|
||||||
state.thread->waitTag = tag;
|
state.thread->waitTag = tag;
|
||||||
state.thread->waitConditionVariable = key;
|
state.thread->waitConditionVariable = key;
|
||||||
state.thread->waitSignalled = false;
|
state.thread->waitSignalled = false;
|
||||||
@ -259,7 +259,7 @@ namespace skyline::kernel::type {
|
|||||||
std::unique_lock lock{state.thread->waiterMutex};
|
std::unique_lock lock{state.thread->waiterMutex};
|
||||||
|
|
||||||
if (state.thread->waitSignalled) {
|
if (state.thread->waitSignalled) {
|
||||||
if (state.thread->waitKey) {
|
if (state.thread->waitMutex) {
|
||||||
auto waitThread{state.thread->waitThread};
|
auto waitThread{state.thread->waitThread};
|
||||||
std::unique_lock waitLock{waitThread->waiterMutex, std::try_to_lock};
|
std::unique_lock waitLock{waitThread->waiterMutex, std::try_to_lock};
|
||||||
if (!waitLock) {
|
if (!waitLock) {
|
||||||
@ -276,7 +276,7 @@ namespace skyline::kernel::type {
|
|||||||
waiters.erase(it);
|
waiters.erase(it);
|
||||||
state.thread->UpdatePriorityInheritance();
|
state.thread->UpdatePriorityInheritance();
|
||||||
|
|
||||||
state.thread->waitKey = nullptr;
|
state.thread->waitMutex = nullptr;
|
||||||
state.thread->waitTag = 0;
|
state.thread->waitTag = 0;
|
||||||
state.thread->waitThread = nullptr;
|
state.thread->waitThread = nullptr;
|
||||||
} else {
|
} else {
|
||||||
@ -284,7 +284,7 @@ namespace skyline::kernel::type {
|
|||||||
shouldWait = true;
|
shouldWait = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the waitKey is null then we were signalled and are no longer waiting on the associated mutex
|
// If the waitMutex is null then we were signalled and are no longer waiting on the associated mutex
|
||||||
shouldWait = true;
|
shouldWait = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -350,7 +350,7 @@ namespace skyline::kernel::type {
|
|||||||
std::scoped_lock lock{thread->waiterMutex};
|
std::scoped_lock lock{thread->waiterMutex};
|
||||||
if (thread->waitConditionVariable == conditionVariable) {
|
if (thread->waitConditionVariable == conditionVariable) {
|
||||||
// If the thread is still waiting on the same condition variable then we can signal it (It could no longer be waiting due to a timeout)
|
// If the thread is still waiting on the same condition variable then we can signal it (It could no longer be waiting due to a timeout)
|
||||||
u32 *mutex{thread->waitKey};
|
u32 *mutex{thread->waitMutex};
|
||||||
KHandle tag{thread->waitTag};
|
KHandle tag{thread->waitTag};
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -63,7 +63,7 @@ namespace skyline {
|
|||||||
bool forceYield{}; //!< If the thread has been forcefully yielded by another thread
|
bool forceYield{}; //!< If the thread has been forcefully yielded by another thread
|
||||||
|
|
||||||
std::recursive_mutex waiterMutex; //!< Synchronizes operations on mutation of the waiter members
|
std::recursive_mutex waiterMutex; //!< Synchronizes operations on mutation of the waiter members
|
||||||
u32 *waitKey; //!< The key of the mutex which this thread is waiting on
|
u32 *waitMutex; //!< The key of the mutex which this thread is waiting on
|
||||||
KHandle waitTag; //!< The handle of the thread which requested the mutex lock
|
KHandle waitTag; //!< The handle of the thread which requested the mutex lock
|
||||||
std::shared_ptr<KThread> waitThread; //!< The thread which this thread is waiting on
|
std::shared_ptr<KThread> waitThread; //!< The thread which this thread is waiting on
|
||||||
std::list<std::shared_ptr<type::KThread>> waiters; //!< A queue of threads waiting on this thread sorted by priority
|
std::list<std::shared_ptr<type::KThread>> waiters; //!< A queue of threads waiting on this thread sorted by priority
|
||||||
|
Loading…
Reference in New Issue
Block a user