mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
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.
This commit is contained in:
parent
259a1d56b0
commit
81d0f96f20
5 changed files with 104 additions and 122 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue