This function is called via syscall (and maybe other mechanism) to remove the current thread.
(_current_context: &mut Context)
| 681 | /// This function is called via syscall (and maybe other mechanism) |
| 682 | /// to remove the current thread. |
| 683 | pub 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 | /// |
no test coverage detected