aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/k_synchronization_object.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-12-12 22:43:25 -0800
committerGitHub <noreply@github.com>2021-12-12 22:43:25 -0800
commit280c77989880e81f622440b157a0ce1b7139847b (patch)
tree49a3ef8127d721dc44effb8315e5db7e796336f4 /src/core/hle/kernel/k_synchronization_object.h
parent429320aee8a0beab0081a61e6e3cfbc6bb754db2 (diff)
parent257d3c9ecf2730fad3b68918f108fa652061cabd (diff)
Merge pull request #7462 from bunnei/kernel-improve-scheduling
Kernel: Improve threading & scheduling V3
Diffstat (limited to 'src/core/hle/kernel/k_synchronization_object.h')
-rw-r--r--src/core/hle/kernel/k_synchronization_object.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h
index 898e58e16..ec235437b 100644
--- a/src/core/hle/kernel/k_synchronization_object.h
+++ b/src/core/hle/kernel/k_synchronization_object.h
@@ -35,6 +35,38 @@ public:
[[nodiscard]] std::vector<KThread*> GetWaitingThreadsForDebugging() const;
+ void LinkNode(ThreadListNode* node_) {
+ // Link the node to the list.
+ if (thread_list_tail == nullptr) {
+ thread_list_head = node_;
+ } else {
+ thread_list_tail->next = node_;
+ }
+
+ thread_list_tail = node_;
+ }
+
+ void UnlinkNode(ThreadListNode* node_) {
+ // Unlink the node from the list.
+ ThreadListNode* prev_ptr =
+ reinterpret_cast<ThreadListNode*>(std::addressof(thread_list_head));
+ ThreadListNode* prev_val = nullptr;
+ ThreadListNode *prev, *tail_prev;
+
+ do {
+ prev = prev_ptr;
+ prev_ptr = prev_ptr->next;
+ tail_prev = prev_val;
+ prev_val = prev_ptr;
+ } while (prev_ptr != node_);
+
+ if (thread_list_tail == node_) {
+ thread_list_tail = tail_prev;
+ }
+
+ prev->next = node_->next;
+ }
+
protected:
explicit KSynchronizationObject(KernelCore& kernel);
~KSynchronizationObject() override;