summaryrefslogtreecommitdiff
path: root/Kernel/Thread.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-07-10 10:23:16 -0600
committerAndreas Kling <kling@serenityos.org>2021-07-12 11:27:18 +0200
commit026ffa343d47fa4caca3c5863880ec53a1a95495 (patch)
treed54853b7f76048c8e2654d90472ad34f0921bc3e /Kernel/Thread.h
parentd9fb93c5ce5f6c8143accec26c5d65460c8f0ea2 (diff)
downloadserenity-026ffa343d47fa4caca3c5863880ec53a1a95495.zip
Kernel: Allow Lock to block from BlockCondition
This enables the Lock class to block a thread even while the thread is working on a BlockCondition. A thread can still only be either blocked by a Lock or a BlockCondition. This also establishes a linked list of threads that are blocked by a Lock and unblocking directly unlocks threads and wakes them directly.
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r--Kernel/Thread.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 2980ea9812..1cb21a66a0 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -116,6 +116,7 @@ class Thread
AK_MAKE_NONCOPYABLE(Thread);
AK_MAKE_NONMOVABLE(Thread);
+ friend class Lock;
friend class Process;
friend class ProtectedProcessBase;
friend class Scheduler;
@@ -823,6 +824,8 @@ public:
}
}
+ void block(Kernel::Lock&, ScopedSpinLock<SpinLock<u8>>&, u32);
+
template<typename BlockerType, class... Args>
[[nodiscard]] BlockResult block(const BlockTimeout& timeout, Args&&... args)
{
@@ -954,6 +957,7 @@ public:
return result;
}
+ u32 unblock_from_lock(Kernel::Lock&);
void unblock_from_blocker(Blocker&);
void unblock(u8 signal = 0);
@@ -1280,6 +1284,9 @@ private:
Optional<Range> m_thread_specific_range;
Array<SignalActionData, NSIG> m_signal_action_data;
Blocker* m_blocker { nullptr };
+ Kernel::Lock* m_blocking_lock { nullptr };
+ u32 m_lock_requested_count { 0 };
+ IntrusiveListNode<Thread> m_blocked_threads_list_node;
bool m_may_die_immediately { true };
#if LOCK_DEBUG