kern: refactor priority inheritance to represent locks as C++ objects

This commit is contained in:
Michael Scire 2023-02-21 13:15:01 -07:00
parent 4f6ecf138b
commit adfaee0f46
7 changed files with 271 additions and 102 deletions

View file

@ -68,13 +68,13 @@ namespace ams::kern {
KScopedSchedulerLock sl;
/* Get the next owner. */
s32 num_waiters;
KThread *next_owner = owner_thread->RemoveWaiterByKey(std::addressof(num_waiters), reinterpret_cast<uintptr_t>(std::addressof(m_tag)));
bool has_waiters;
KThread *next_owner = owner_thread->RemoveWaiterByKey(std::addressof(has_waiters), reinterpret_cast<uintptr_t>(std::addressof(m_tag)));
/* Pass the lock to the next owner. */
uintptr_t next_tag = 0;
if (next_owner != nullptr) {
next_tag = reinterpret_cast<uintptr_t>(next_owner) | static_cast<uintptr_t>(num_waiters > 1);
next_tag = reinterpret_cast<uintptr_t>(next_owner) | static_cast<uintptr_t>(has_waiters);
next_owner->EndWait(ResultSuccess());