exit-wait.c

来自「用于汇编领域的,运用于OS的MAIN函数.基于硬件基础的源代码」· C语言 代码 · 共 32 行

C
32 行
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?