mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Remove status code from thread exit
The status code from thread exit had too many issues, (eg, how does it relate to process exit code? what happens when different threads exit with different exit codes?) and not enough value, so I'm getting rid of it.
This commit is contained in:
@@ -55,7 +55,7 @@ process::exit(int32_t code)
|
||||
m_return_code = code;
|
||||
|
||||
for (auto *thread : m_threads) {
|
||||
thread->exit(code);
|
||||
thread->exit();
|
||||
}
|
||||
|
||||
if (this == current_cpu().process)
|
||||
@@ -68,21 +68,17 @@ process::update()
|
||||
kassert(m_threads.count() > 0, "process::update with zero threads!");
|
||||
|
||||
size_t i = 0;
|
||||
uint32_t status = 0;
|
||||
while (i < m_threads.count()) {
|
||||
thread *th = m_threads[i];
|
||||
if (th->has_state(thread::state::exited)) {
|
||||
status = th->m_return_code;
|
||||
m_threads.remove_swap_at(i);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (m_threads.count() == 0) {
|
||||
// TODO: What really is the return code in this case?
|
||||
exit(status);
|
||||
}
|
||||
if (m_threads.count() == 0)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
thread *
|
||||
@@ -106,7 +102,6 @@ bool
|
||||
process::thread_exited(thread *th)
|
||||
{
|
||||
kassert(&th->m_parent == this, "Process got thread_exited for non-child!");
|
||||
uint32_t status = th->m_return_code;
|
||||
m_threads.remove_swap(th);
|
||||
remove_handle(th->self_handle());
|
||||
delete th;
|
||||
@@ -114,7 +109,7 @@ process::thread_exited(thread *th)
|
||||
// TODO: delete the thread's stack VMA
|
||||
|
||||
if (m_threads.count() == 0) {
|
||||
exit(status);
|
||||
exit(-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,11 +71,11 @@ thread::wake_only()
|
||||
}
|
||||
|
||||
void
|
||||
thread::exit(int32_t code)
|
||||
thread::exit()
|
||||
{
|
||||
m_return_code = code;
|
||||
m_wake_timeout = 0;
|
||||
set_state(state::exited);
|
||||
m_join_queue.clear();
|
||||
block();
|
||||
}
|
||||
|
||||
|
||||
@@ -138,8 +138,7 @@ public:
|
||||
inline process & parent() { return m_parent; }
|
||||
|
||||
/// Terminate this thread.
|
||||
/// \arg code The return code to exit with.
|
||||
void exit(int32_t code);
|
||||
void exit();
|
||||
|
||||
/// Add a stack header that returns to the given address in kernel space.
|
||||
/// \arg rip The address to return to, must be kernel space
|
||||
@@ -188,10 +187,6 @@ private:
|
||||
|
||||
state m_state;
|
||||
|
||||
// There should be 3 bytes of padding here
|
||||
|
||||
int32_t m_return_code;
|
||||
|
||||
uint64_t m_wake_value;
|
||||
uint64_t m_wake_timeout;
|
||||
message_data m_message_data;
|
||||
|
||||
Reference in New Issue
Block a user