summaryrefslogtreecommitdiff
path: root/Kernel/Process.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-12-21 23:21:58 -0700
committerAndreas Kling <kling@serenityos.org>2021-01-17 20:30:31 +0100
commit1d621ab1725d1eba0fafef4575aef72682cd57ad (patch)
treeb30a1d63d09e70722fe04a45c6e96522d3a295bc /Kernel/Process.h
parent7581b64705ed3c5b3711c956504f278c2ea3899e (diff)
downloadserenity-1d621ab1725d1eba0fafef4575aef72682cd57ad.zip
Kernel: Some futex improvements
This adds support for FUTEX_WAKE_OP, FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET, FUTEX_REQUEUE, and FUTEX_CMP_REQUEUE, as well well as global and private futex and absolute/relative timeouts against the appropriate clock. This also changes the implementation so that kernel resources are only used when a thread is blocked on a futex. Global futexes are implemented as offsets in VMObjects, so that different processes can share a futex against the same VMObject despite potentially being mapped at different virtual addresses.
Diffstat (limited to 'Kernel/Process.h')
-rw-r--r--Kernel/Process.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 72d8be3ba9..1b5922d053 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -38,6 +38,7 @@
#include <Kernel/API/Syscall.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Forward.h>
+#include <Kernel/FutexQueue.h>
#include <Kernel/Lock.h>
#include <Kernel/ProcessGroup.h>
#include <Kernel/StdLib.h>
@@ -94,6 +95,8 @@ enum class VeilState {
Locked,
};
+typedef HashMap<FlatPtr, RefPtr<FutexQueue>> FutexQueues;
+
class Process
: public RefCounted<Process>
, public InlineLinkedListNode<Process>
@@ -542,6 +545,8 @@ private:
bool has_tracee_thread(ProcessID tracer_pid);
+ void clear_futex_queues_on_exec();
+
RefPtr<PageDirectory> m_page_directory;
Process* m_prev { nullptr };
@@ -637,11 +642,11 @@ private:
VeilState m_veil_state { VeilState::None };
UnveilNode m_unveiled_paths { "/", { .full_path = "/", .unveil_inherited_from_root = true } };
- WaitQueue& futex_queue(Userspace<const i32*>);
- HashMap<u32, OwnPtr<WaitQueue>> m_futex_queues;
-
OwnPtr<PerformanceEventBuffer> m_perf_event_buffer;
+ FutexQueues m_futex_queues;
+ SpinLock<u8> m_futex_lock;
+
// This member is used in the implementation of ptrace's PT_TRACEME flag.
// If it is set to true, the process will stop at the next execve syscall
// and wait for a tracer to attach.