mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 01:16:26 +04:00
bugfix #144: Do not free kstack when the main thread exits
This commit is contained in:
parent
03c4188c08
commit
aaab6d3dd6
@ -127,6 +127,13 @@ pub fn exit_current_and_run_next(exit_code: i32) {
|
|||||||
process_inner.memory_set.recycle_data_pages();
|
process_inner.memory_set.recycle_data_pages();
|
||||||
// drop file descriptors
|
// drop file descriptors
|
||||||
process_inner.fd_table.clear();
|
process_inner.fd_table.clear();
|
||||||
|
// Remove all tasks except for the main thread itself.
|
||||||
|
// This is because we are still using the kstack under the TCB
|
||||||
|
// of the main thread. This TCB, including its kstack, will be
|
||||||
|
// deallocated when the process is reaped via waitpid.
|
||||||
|
while process_inner.tasks.len() > 1 {
|
||||||
|
process_inner.tasks.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
drop(process);
|
drop(process);
|
||||||
// we do not have to save task context
|
// we do not have to save task context
|
||||||
|
Loading…
Reference in New Issue
Block a user