|
/// Exit current task |
|
/// TODO: Should be reimplemented with URM |
|
pub fn exit_task() noreturn { |
|
const task = os.platform.thread.self_exited(); |
|
const id = if (task) |t| t.allocated_core_id else 0; |
|
|
|
const state = balancer_lock.lock(); |
|
os.platform.smp.cpus[id].tasks_count -= 1; |
|
balancer_lock.unlock(state); |
|
|
|
if(task) |t| { |
|
task_alloc.destroy(t); |
|
} |
|
|
|
leave(); |
|
} |
As of now, task termination leaks stacks. Furthermore, on x86, TSSes are leaked as well.
There are two possible ways of handling thread termination
- User Request Monitor thread that will wait for requests to terminate. Threads will enqueue them in some queue and User Request Monitor will dispose resources associated with them (both common like stacks and platform-specific like TSS)
- Per-cpu stack locked by mutex to which threads will switch to deallocate whatever they need to deallocate. For TSS on x86, some temporatory TSS should be loaded with correct interrupt and scheduler stacks
Florence/src/thread/scheduler.zig
Lines 82 to 97 in 8d788c0
As of now, task termination leaks stacks. Furthermore, on x86, TSSes are leaked as well.
There are two possible ways of handling thread termination