From: Ben Gras Date: Thu, 20 Oct 2005 20:59:02 +0000 (+0000) Subject: . check for notify() from NONE (shouldn't happen any more) X-Git-Tag: v3.1.2a~583 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=cf16c73e62caedf95715dbba616500865498732c;p=minix.git . check for notify() from NONE (shouldn't happen any more) . test for cleared process slots when checking processes on exiting . clear process slot first, then do cleanup on exiting --- diff --git a/kernel/proc.c b/kernel/proc.c index ec92b52d2..125c34363 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -349,6 +349,11 @@ unsigned flags; /* system call flags */ src_id = (chunk - &map->chunk[0]) * BITCHUNK_BITS + i; if (src_id >= NR_SYS_PROCS) break; /* out of range */ src_proc_nr = id_to_nr(src_id); /* get source proc */ +#if DEBUG_ENABLE_IPC_WARNINGS + if(src_proc_nr == NONE) { + kprintf("mini_receive: sending notify from NONE\n"); + } +#endif if (src!=ANY && src!=src_proc_nr) continue; /* source not ok */ *chunk &= ~(1 << i); /* no longer pending */ diff --git a/kernel/system/do_exit.c b/kernel/system/do_exit.c index fd6b6fc0b..f6a28d060 100644 --- a/kernel/system/do_exit.c +++ b/kernel/system/do_exit.c @@ -49,6 +49,11 @@ register struct proc *rc; /* slot of process to clean up */ register struct proc *rp; /* iterate over process table */ register struct proc **xpp; /* iterate over caller queue */ int i; + int sys_id; + char rts_flags; + + /* Don't clear if already cleared. */ + if(isemptyp(rc)) return; /* Turn off any alarm timers at the clock. */ reset_timer(&priv(rc)->s_alarm_timer); @@ -56,11 +61,20 @@ register struct proc *rc; /* slot of process to clean up */ /* Make sure that the exiting process is no longer scheduled. */ if (rc->p_rts_flags == 0) lock_dequeue(rc); + /* Release the process table slot. If this is a system process, also + * release its privilege structure. Further cleanup is not needed at + * this point. All important fields are reinitialized when the + * slots are assigned to another, new process. + */ + rts_flags = rc->p_rts_flags; + rc->p_rts_flags = SLOT_FREE; + if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE; + /* If the process being terminated happens to be queued trying to send a * message (e.g., the process was killed by a signal, rather than it doing * a normal exit), then it must be removed from the message queues. */ - if (rc->p_rts_flags & SENDING) { + if (rts_flags & SENDING) { xpp = &proc[rc->p_sendto].p_caller_q; /* destination's queue */ while (*xpp != NIL_PROC) { /* check entire queue */ if (*xpp == rc) { /* process is on the queue */ @@ -80,6 +94,8 @@ register struct proc *rc; /* slot of process to clean up */ * Check all processes. */ for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) { + if(isemptyp(rp)) + continue; /* Unset pending notification bits. */ unset_sys_bit(priv(rp)->s_notify_pending, priv(rc)->s_id); @@ -114,14 +130,6 @@ register struct proc *rc; /* slot of process to clean up */ /* Clean up virtual memory */ if (rc->p_misc_flags & MF_VM) vm_map_default(rc); - - /* Now it is safe to release the process table slot. If this is a system - * process, also release its privilege structure. Further cleanup is not - * needed at this point. All important fields are reinitialized when the - * slots are assigned to another, new process. - */ - rc->p_rts_flags = SLOT_FREE; - if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE; } #endif /* USE_EXIT */