code:stop - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 跟踪 系统中,子进程进入SSTOP状态,响应跟踪请求
4009
4010 /*
4011 * Enter the tracing STOP state.
4012 * In this state, the parent is
4013 * informed and the process is able to
4014 * receive commands from the parent.
4015 */
4016 stop()
4017 {
4018 register struct proc *pp, *cp;
4019
4020 loop:
4021 cp = u.u_procp;
4022 if(cp->p_ppid != 1)
4023 for (pp = &proc[0]; pp < &proc[NPROC]; pp++)疑为笔误
- LIONS 源代码为
4022 if(cp->p_pid != 1)
4024 if (pp->p_pid == cp->p_ppid) {
4025 wakeup(pp);
- pp ← 现行进程的父进程
4026 cp->p_stat = SSTOP;
4027 swtch();
- 唤醒 父进程
- 子进程 置 SSTOP
- 要求进程切换
4028 if ((cp->p_flag&STRC)==0 || procxmt())
- 当 父进程 提出了跟踪请求,且子进程再次切换上台,继续执行
4029 return;
4030 goto loop;
- 以下情况 函数返回
- 子进程 STRC 被清 (不再进行跟踪)
- 父进程 向 子进程 发送信号(procxmt() == 1)
4031 }
4032 exit();
4033 }(父进程 已经退出,子进程托管给1#进程) (已经没有必要继续跟踪了)
- 以下情况 进程终止
- 子进程 的 父进程 为 1#进程
4034 /* ------------------------- */