diff options
author | Drew Stratford <drewstratford@outlook.com> | 2019-09-05 01:14:54 +1200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-05 16:37:09 +0200 |
commit | 81d0f96f200d81266554b3c6efbf8a7c9737cfe1 (patch) | |
tree | 3ee3b10635a81208b05d6853f16f525801f36043 /Kernel/Thread.h | |
parent | 259a1d56b04809690716fe0576fad9ea12782ce9 (diff) | |
download | serenity-81d0f96f200d81266554b3c6efbf8a7c9737cfe1.zip |
Kernel: Use user stack for signal handlers.
This commit drastically changes how signals are handled.
In the case that an unblocked thread is signaled it works much
in the same way as previously. However, when a blocking syscall
is interrupted, we set up the signal trampoline on the user
stack, complete the blocking syscall, return down the kernel
stack and then jump to the handler. This means that from the
kernel stack's perspective, we only ever get one system call deep.
The signal trampoline has also been changed in order to properly
store the return value from system calls. This is necessary due
to the new way we exit from signaled system calls.
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r-- | Kernel/Thread.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 6c1f481212..42357e4b53 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -6,9 +6,9 @@ #include <AK/OwnPtr.h> #include <AK/RefPtr.h> #include <AK/Vector.h> -#include <Kernel/Scheduler.h> #include <Kernel/Arch/i386/CPU.h> #include <Kernel/KResult.h> +#include <Kernel/Scheduler.h> #include <Kernel/UnixTypes.h> #include <Kernel/VM/Region.h> #include <LibC/fd_set.h> @@ -73,6 +73,7 @@ public: virtual const char* state_string() const = 0; void set_interrupted_by_signal() { m_was_interrupted_while_blocked = true; } bool was_interrupted_by_signal() const { return m_was_interrupted_while_blocked; } + private: bool m_was_interrupted_while_blocked { false }; friend class Thread; @@ -220,8 +221,8 @@ public: InterruptedBySignal, }; - template <typename T, class... Args> - [[nodiscard]] BlockResult block(Args&& ... args) + template<typename T, class... Args> + [[nodiscard]] BlockResult block(Args&&... args) { // We should never be blocking a blocked (or otherwise non-active) thread. ASSERT(state() == Thread::Running); @@ -295,6 +296,7 @@ public: void set_has_used_fpu(bool b) { m_has_used_fpu = b; } void set_default_signal_dispositions(); + void push_value_on_user_stack(RegisterDump&, u32); void push_value_on_stack(u32); void make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment); void make_userspace_stack_for_secondary_thread(void* argument); |