Kernel: Restructure process and thread termination
When we want to kill a process, we mark its threads as Terminating or Terminated. If the thread is in critical section that has to be finished, it will be in Terminating state until done. Once Scheduler is trying to execute Terminated thread it will instead delete it. Once processes last thread is marked Terminated, the processes will turn it into a cleanup thread, that will allow blocks and memory cleanup to be done.
This commit is contained in:
@@ -20,9 +20,6 @@ namespace Kernel
|
||||
void reschedule_if_idling();
|
||||
|
||||
void set_current_thread_sleeping(uint64_t);
|
||||
[[noreturn]] void set_current_thread_done();
|
||||
|
||||
[[noreturn]] void set_current_process_done();
|
||||
|
||||
void block_current_thread(Semaphore*);
|
||||
void unblock_threads(Semaphore*);
|
||||
@@ -33,6 +30,8 @@ namespace Kernel
|
||||
|
||||
static bool is_valid_tid(pid_t tid);
|
||||
|
||||
[[noreturn]] void delete_current_process_and_thread();
|
||||
|
||||
private:
|
||||
Scheduler() = default;
|
||||
|
||||
@@ -76,6 +75,7 @@ namespace Kernel
|
||||
|
||||
uint64_t m_last_reschedule = 0;
|
||||
|
||||
friend class Thread;
|
||||
friend class Process;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user