Skip to content

thread: Handle task termination properly #42

@notYuriy

Description

@notYuriy

/// 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions