mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +00:00
kern: update for 11.0.1
This commit is contained in:
parent
be8473cf65
commit
7fb902d8fb
2 changed files with 30 additions and 14 deletions
|
@ -30,9 +30,10 @@ namespace ams::kern {
|
||||||
KThread *thread;
|
KThread *thread;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
ThreadListNode *thread_list_root;
|
ThreadListNode *thread_list_head;
|
||||||
|
ThreadListNode *thread_list_tail;
|
||||||
protected:
|
protected:
|
||||||
constexpr ALWAYS_INLINE explicit KSynchronizationObject() : KAutoObjectWithList(), thread_list_root() { MESOSPHERE_ASSERT_THIS(); }
|
constexpr ALWAYS_INLINE explicit KSynchronizationObject() : KAutoObjectWithList(), thread_list_head(), thread_list_tail() { MESOSPHERE_ASSERT_THIS(); }
|
||||||
virtual ~KSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }
|
virtual ~KSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }
|
||||||
|
|
||||||
virtual void OnFinalizeSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }
|
virtual void OnFinalizeSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }
|
||||||
|
|
|
@ -81,8 +81,15 @@ namespace ams::kern {
|
||||||
/* Add the waiters. */
|
/* Add the waiters. */
|
||||||
for (auto i = 0; i < num_objects; ++i) {
|
for (auto i = 0; i < num_objects; ++i) {
|
||||||
thread_nodes[i].thread = thread;
|
thread_nodes[i].thread = thread;
|
||||||
thread_nodes[i].next = objects[i]->thread_list_root;
|
thread_nodes[i].next = nullptr;
|
||||||
objects[i]->thread_list_root = std::addressof(thread_nodes[i]);
|
|
||||||
|
if (objects[i]->thread_list_tail == nullptr) {
|
||||||
|
objects[i]->thread_list_head = std::addressof(thread_nodes[i]);
|
||||||
|
} else {
|
||||||
|
objects[i]->thread_list_tail->next = std::addressof(thread_nodes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
objects[i]->thread_list_tail = std::addressof(thread_nodes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark the thread as waiting. */
|
/* Mark the thread as waiting. */
|
||||||
|
@ -111,11 +118,22 @@ namespace ams::kern {
|
||||||
|
|
||||||
for (auto i = 0; i < num_objects; ++i) {
|
for (auto i = 0; i < num_objects; ++i) {
|
||||||
/* Unlink the object from the list. */
|
/* Unlink the object from the list. */
|
||||||
ThreadListNode **link = std::addressof(objects[i]->thread_list_root);
|
ThreadListNode *prev_ptr = reinterpret_cast<ThreadListNode *>(std::addressof(objects[i]->thread_list_head));
|
||||||
while (*link != std::addressof(thread_nodes[i])) {
|
ThreadListNode *prev_val = nullptr;
|
||||||
link = std::addressof((*link)->next);
|
ThreadListNode *prev, *tail_prev;
|
||||||
|
|
||||||
|
do {
|
||||||
|
prev = prev_ptr;
|
||||||
|
prev_ptr = prev_ptr->next;
|
||||||
|
tail_prev = prev_val;
|
||||||
|
prev_val = prev_ptr;
|
||||||
|
} while (prev_ptr != std::addressof(thread_nodes[i]));
|
||||||
|
|
||||||
|
if (objects[i]->thread_list_tail == std::addressof(thread_nodes[i])) {
|
||||||
|
objects[i]->thread_list_tail = tail_prev;
|
||||||
}
|
}
|
||||||
*link = thread_nodes[i].next;
|
|
||||||
|
prev->next = thread_nodes[i].next;
|
||||||
|
|
||||||
if (objects[i] == synced_obj) {
|
if (objects[i] == synced_obj) {
|
||||||
sync_index = i;
|
sync_index = i;
|
||||||
|
@ -139,7 +157,7 @@ namespace ams::kern {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate over each thread. */
|
/* Iterate over each thread. */
|
||||||
for (auto *cur_node = this->thread_list_root; cur_node != nullptr; cur_node = cur_node->next) {
|
for (auto *cur_node = this->thread_list_head; cur_node != nullptr; cur_node = cur_node->next) {
|
||||||
KThread *thread = cur_node->thread;
|
KThread *thread = cur_node->thread;
|
||||||
if (thread->GetState() == KThread::ThreadState_Waiting) {
|
if (thread->GetState() == KThread::ThreadState_Waiting) {
|
||||||
thread->SetSyncedObject(this, result);
|
thread->SetSyncedObject(this, result);
|
||||||
|
@ -158,8 +176,7 @@ namespace ams::kern {
|
||||||
|
|
||||||
MESOSPHERE_RELEASE_LOG("Threads waiting on %p:\n", this);
|
MESOSPHERE_RELEASE_LOG("Threads waiting on %p:\n", this);
|
||||||
|
|
||||||
bool has_waiters = false;
|
for (auto *cur_node = this->thread_list_head; cur_node != nullptr; cur_node = cur_node->next) {
|
||||||
for (auto *cur_node = this->thread_list_root; cur_node != nullptr; cur_node = cur_node->next) {
|
|
||||||
KThread *thread = cur_node->thread;
|
KThread *thread = cur_node->thread;
|
||||||
|
|
||||||
if (KProcess *process = thread->GetOwnerProcess(); process != nullptr) {
|
if (KProcess *process = thread->GetOwnerProcess(); process != nullptr) {
|
||||||
|
@ -167,12 +184,10 @@ namespace ams::kern {
|
||||||
} else {
|
} else {
|
||||||
MESOSPHERE_RELEASE_LOG(" %p tid=%ld (Kernel)\n", thread, thread->GetId());
|
MESOSPHERE_RELEASE_LOG(" %p tid=%ld (Kernel)\n", thread, thread->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
has_waiters = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we didn't have any waiters, print so. */
|
/* If we didn't have any waiters, print so. */
|
||||||
if (!has_waiters) {
|
if (this->thread_list_head != nullptr) {
|
||||||
MESOSPHERE_RELEASE_LOG(" None\n");
|
MESOSPHERE_RELEASE_LOG(" None\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue