mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
Kernel: Allow process with multiple threads to call exec and exit
This allows a process wich has more than 1 thread to call exec, even from a thread. This kills all the other threads, but it won't wait for them to finish, just makes sure that they are not in a running/runable state. In the case where a thread does exec, the new program PID will be the thread TID, to keep the PID == TID in the new process. This introduces a new function inside the Process class, kill_threads_except_self which is called on exit() too (exit with multiple threads wasn't properly working either). Inside the Lock class, there is the need for a new function, clear_waiters, which removes all the waiters from the Process::big_lock. This is needed since after a exit/exec, there should be no other threads waiting for this lock, the threads should be simply killed. Only queued threads should wait for this lock at this point, since blocked threads are handled in set_should_die.
This commit is contained in:
parent
9fcb37ad30
commit
717cd5015e
8 changed files with 78 additions and 22 deletions
|
@ -162,11 +162,17 @@ Thread::~Thread()
|
|||
void Thread::unblock()
|
||||
{
|
||||
if (current == this) {
|
||||
set_state(Thread::Running);
|
||||
if (m_should_die)
|
||||
set_state(Thread::Dying);
|
||||
else
|
||||
set_state(Thread::Running);
|
||||
return;
|
||||
}
|
||||
ASSERT(m_state != Thread::Runnable && m_state != Thread::Running);
|
||||
set_state(Thread::Runnable);
|
||||
if (m_should_die)
|
||||
set_state(Thread::Dying);
|
||||
else
|
||||
set_state(Thread::Runnable);
|
||||
}
|
||||
|
||||
void Thread::set_should_die()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue