1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Kernel: Fix signal delivery

When delivering urgent signals to the current thread
we need to check if we should be unblocked, and if not
we need to yield to another process.

We also need to make sure that we suppress context switches
during Process::exec() so that we don't clobber the registers
that it sets up (eip mainly) by a context switch. To be able
to do that we add the concept of a critical section, which are
similar to Process::m_in_irq but different in that they can be
requested at any time. Calls to Scheduler::yield and
Scheduler::donate_to will return instantly without triggering
a context switch, but the processor will then asynchronously
trigger a context switch once the critical section is left.
This commit is contained in:
Tom 2020-07-03 05:19:50 -06:00 committed by Andreas Kling
parent a308b176ce
commit e373e5f007
12 changed files with 242 additions and 95 deletions

View file

@ -450,6 +450,7 @@ public:
void increment_inspector_count(Badge<ProcessInspectionHandle>) { ++m_inspector_count; }
void decrement_inspector_count(Badge<ProcessInspectionHandle>) { --m_inspector_count; }
bool wait_for_tracer_at_next_execve() const { return m_wait_for_tracer_at_next_execve; }
void set_wait_for_tracer_at_next_execve(bool val) { m_wait_for_tracer_at_next_execve = val; }
KResultOr<u32> peek_user_data(u32* address);
@ -470,7 +471,7 @@ private:
void kill_threads_except_self();
void kill_all_threads();
int do_exec(NonnullRefPtr<FileDescription> main_program_description, Vector<String> arguments, Vector<String> environment, RefPtr<FileDescription> interpreter_description);
int do_exec(NonnullRefPtr<FileDescription> main_program_description, Vector<String> arguments, Vector<String> environment, RefPtr<FileDescription> interpreter_description, Thread*& new_main_thread, u32& prev_flags);
ssize_t do_write(FileDescription&, const u8*, int data_size);
KResultOr<NonnullRefPtr<FileDescription>> find_elf_interpreter_for_executable(const String& path, char (&first_page)[PAGE_SIZE], int nread, size_t file_size);