code:psig - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
4035
4036 /*
4037 * Perform the action specified by
4038 * the current signal.
4039 * The usual sequence is:
4040 * if(issig())
4041 * psig();
4042 */
4043 psig()
4044 {
4045 register n, p;
4046 register *rp;
4047
4048 rp = u.u_procp;
4049 n = rp->p_sig;
4050 rp->p_sig = 0;
4051 if((p=u.u_signal[n]) != 0) {
- 清 信号
4052 u.u_error = 0;
- 若 信号处理 不为 缺省,则...
4053 if(n != SIGINS && n != SIGTRC)
4054 u.u_signal[n] = 0;
4055 n = u.u_ar0[R6] - 4;
- 信号 不为 SIGINS 或 SIGTRC,则信号处理方式 置为 缺省
4056 grow(n);
4057 suword(n+2, u.u_ar0[RPS]);
4059 u.u_ar0[R6] = n;
- 向 用户栈 压入 当前中断保护的pc,ps
- 设为 pc0,ps0
- 参看 说明
4060 u.u_ar0[RPS] =& ~TBIT;
4061 u.u_ar0[R7] = p;
4062 return;
- 将 当前中断保护 的pc 置为 信号处理函数的入口
- 将 当前中断保护 的ps 清 T(陷入) 位
- 设为 pc1,ps1
- 修正 用户栈栈顶
- 参看 说明
4063 }
4064 switch(n) {
- 当 使用缺省的信号处理方式,执行以下代码
4065
4066 case SIGQIT:
4067 case SIGINS:
4068 case SIGTRC:
4069 case SIGIOT:
4070 case SIGEMT:
4071 case SIGFPT:
4072 case SIGBUS:
4073 case SIGSEG:
4074 case SIGSYS:
4075 u.u_arg[0] = n;
4076 if(core())
4077 n =+ 0200;
4078 }
- 生成 内存映像文件,方便debug
4079 u.u_arg[0] = (u.u_ar0[R0]<<8) | n;
4080 exit();
4081 }
- 终止 本进程
4082 /* ------------------------- */