📄 exit-wait.c
字号:
// exit and wait system call#include "hos.h"void release_body(struct task_struct *p){//free the body of p unsigned long *dir=(unsigned long *)(mloc(p->mm.pgdir[0])); free_pgframe(mloc(dir[USER_PAGE])); // free the loaded program frame free_pgframe(p->mm.pgdir); // free the directory table free_pgframe(dir); // free the directory 0 frame printk("frame freeed: %x %x %x\n", mloc(dir[USER_PAGE]), p->mm.pgdir, dir);}void do_exit(){ printk("in do_exit\n"); remove_from_run_q(current); release_body(current); // wake up parent wake_up(current->parent); current->need_reschedule=1; // parent will kill this process later}void do_wait(){ // for now, we assume parent always wait() bef child struct task_struct *child; printk("in do_wait\n"); remove_from_run_q(current); current->need_reschedule=1; // to activate schedule() schedule(); // schedule next process // if we are here, our child is dead. clean him child=find_child(current); remove_from_process_q(child); child->pid=-1; // kill it permanently}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -