[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:
@@ -13,9 +13,7 @@ object thread : object {
|
||||
|
||||
method kill [destructor cap:kill]
|
||||
|
||||
method exit [static] {
|
||||
param status int32
|
||||
}
|
||||
method exit [static]
|
||||
|
||||
method sleep [static] {
|
||||
param duration uint64
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,25 +28,25 @@ thread_create(j6_handle_t *self, process *proc, uintptr_t stack_top, uintptr_t e
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread_exit(int32_t status)
|
||||
{
|
||||
thread &th = thread::current();
|
||||
log::verbose(logs::task, "Thread %llx exiting with code %d", th.koid(), status);
|
||||
th.exit(status);
|
||||
|
||||
log::error(logs::task, "returned to exit syscall");
|
||||
return j6_err_unexpected;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread_kill(thread *self)
|
||||
{
|
||||
log::verbose(logs::task, "Killing thread %llx", self->koid());
|
||||
self->exit(-1);
|
||||
self->exit();
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread_exit()
|
||||
{
|
||||
thread &th = thread::current();
|
||||
log::verbose(logs::task, "Thread %llx exiting", th.koid());
|
||||
th.exit();
|
||||
|
||||
log::error(logs::task, "returned to exit syscall");
|
||||
return j6_err_unexpected;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread_sleep(uint64_t duration)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ channel_pump_loop()
|
||||
void
|
||||
pump_proc()
|
||||
{
|
||||
j6_thread_exit(channel_pump_loop());
|
||||
j6_process_exit(channel_pump_loop());
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user