[kernel] Exit the current thread last on process exit

Previously process::exit() was going through the threads in order
calling thread::exit() - which blocks and never wakes if called on the
current thread. Since the current thread likely belongs to the process
which is exiting, and the current thread wasn't guaranteed to be last in
the list, this could leave threads not cleaned up.

Worse, no matter what, this caused the m_threads_lock to always be held
forever on exit, keeping the scheduler from ever finishing a call to
process::thread_exited() on its threads.
This commit is contained in:
Justin C. Miller
2023-02-18 13:58:23 -08:00
parent 7b29ba7d23
commit e250aaef30
2 changed files with 12 additions and 7 deletions

View File

@@ -82,6 +82,9 @@ public:
/// Get the size of the array.
inline count_t count() const { return m_size; }
/// Check if the array is empty
inline bool empty() const { return m_size == 0; }
/// Get the capacity of the array. This is the amount of space
/// actually allocated.
inline count_t capacity() const { return m_capacity & cap_mask; }