MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / exit_current_thread

Function exit_current_thread

kernel/src/process.rs:683–701  ·  view source on GitHub ↗

This function is called via syscall (and maybe other mechanism) to remove the current thread.

(_current_context: &mut Context)

Source from the content-addressed store, hash-verified

681/// This function is called via syscall (and maybe other mechanism)
682/// to remove the current thread.
683pub fn exit_current_thread(_current_context: &mut Context) {
684 {
685 let mut current_thread = CURRENT_THREAD.write();
686
687 if let Some(_thread) = current_thread.take() {
688 // Drop thread, freeing stacks. If this is the last thread
689 // in this process, memory and page tables will be freed
690 // in the Process drop() function
691 }
692 }
693 // Can't return from this syscall, so this thread now waits for a
694 // timer interrupt to switch context.
695 unsafe {
696 asm!("sti",
697 "2:",
698 "hlt",
699 "jmp 2b");
700 }
701}
702
703/// This is called by the timer interrupt handler
704///

Callers 1

dispatch_syscallFunction · 0.85

Calls 2

takeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected