Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread: Handle task termination properly #42

Open
notYuriy opened this issue May 13, 2021 · 0 comments
Open

thread: Handle task termination properly #42

notYuriy opened this issue May 13, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@notYuriy
Copy link
Contributor

/// 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
@notYuriy notYuriy added the enhancement New feature or request label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant