From: Jorrit Herder Date: Wed, 20 Jul 2005 15:27:42 +0000 (+0000) Subject: Fixed bug in PM that caused update program not to be scheduled, so that X-Git-Tag: v3.1.0~584 X-Git-Url: http://zhaoyanbai.com/repos/doc/tz-art.htm?a=commitdiff_plain;h=f1153541c7c10283b1d09296a6cd15776bd653a8;p=minix.git Fixed bug in PM that caused update program not to be scheduled, so that sync was not periodically run. Chain of timers was accidentially broken. Kernel sends SIGKSTOP signal on shutdown. FS calls sync to clean up. --- diff --git a/servers/fs/fs_timers.h b/servers/fs/fs_timers.h deleted file mode 100644 index b6c53ebe9..000000000 --- a/servers/fs/fs_timers.h +++ /dev/null @@ -1,3 +0,0 @@ - -#include - diff --git a/servers/fs/main.c b/servers/fs/main.c index c10692238..fbac0851f 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -15,6 +15,7 @@ struct super_block; /* proto.h needs to know this */ #include "fs.h" #include #include +#include #include #include #include @@ -48,6 +49,7 @@ PUBLIC void main() * three major activities: getting new work, processing the work, and sending * the reply. This loop never terminates as long as the file system runs. */ + sigset_t sigset; int error; fs_init(); @@ -60,18 +62,18 @@ PUBLIC void main() super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */ /* Check for special control messages first. */ -#if DEAD_CODE - if (call_nr == HARD_STOP) { - do_sync(); - sys_exit(0); /* never returns */ - } else -#endif - if(call_nr == SYN_ALARM) { + if (call_nr == SYS_EVENT) { + sigset = m_in.NOTIFY_ARG; + if (sigismember(&sigset, SIGKSTOP)) { + do_sync(); + sys_exit(0); /* never returns */ + } + } else if (call_nr == SYN_ALARM) { /* Not a user request; system has expired one of our timers, * currently only in use for select(). Check it. */ fs_expire_timers(m_in.NOTIFY_TIMESTAMP); - } else if(call_nr == DEV_SELECTED) { + } else if (call_nr == DEV_SELECTED) { /* Device notify()s us of fd that has become usable. */ select_notified(&m_in); } else { diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index 56e9aefc9..ad41ed605 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -322,7 +322,7 @@ PUBLIC void privileges_dmp() return; } - printf("\n--nr-id-name---- -sanity- -flags- -sc-\n"); + printf("\n--nr-id-name--- -flags- -sc-\n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; @@ -333,8 +333,8 @@ PUBLIC void privileges_dmp() r = -1; for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++) if (sp->s_proc_nr == rp->p_nr) { r ++; break; } - if (r == -1) { - printf("... warning, no privileges found!\n"); + if (r == -1 && ! (rp->p_rts_flags & SLOT_FREE)) { + printf("... no privileges found, probaly a user process\n"); continue; } printf("(%02u) %-7.7s %3x %02.2u", diff --git a/servers/is/main.c b/servers/is/main.c index 0923f8251..083fc52d5 100644 --- a/servers/is/main.c +++ b/servers/is/main.c @@ -57,12 +57,13 @@ PUBLIC void main(void) case SYS_EVENT: sigset = (sigset_t) m_in.NOTIFY_ARG; if (sigismember(&sigset, SIGKMESS)) { - printf("IS proc SIGKMESS\n"); result = do_new_kmess(&m_in); - } else if (sigismember(&sigset, SIGTERM)) { - printf("IS proc SIGTERM\n"); - } else { - report("IS","warning, got unknown signal", NO_NUM); + } + if (sigismember(&sigset, SIGTERM)) { + /* nothing to do on shutdown */ + } + if (sigismember(&sigset, SIGKSTOP)) { + /* nothing to do on shutdown */ } continue; case DIAGNOSTICS: diff --git a/servers/pm/exec.c b/servers/pm/exec.c index e675a426f..39021e82b 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -176,8 +176,9 @@ PUBLIC int do_exec() if (basename == NULL) basename = name; else basename++; strncpy(rmp->mp_name, basename, PROC_NAME_LEN-1); rmp->mp_name[PROC_NAME_LEN] = '\0'; - sys_exec(who, new_sp, rmp->mp_flags & TRACED, basename, pc); + sys_exec(who, new_sp, basename, pc); + /* Cause a signal if this process is traced. */ if (rmp->mp_flags & TRACED) check_sig(rmp->mp_pid, SIGTRAP); return(SUSPEND); /* no reply, new program just runs */ diff --git a/servers/pm/signal.c b/servers/pm/signal.c index e1b874c70..18b3cef2c 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -355,6 +355,7 @@ struct timer *tp; proc_nr = tmr_arg(tp)->ta_int; /* get process from timer */ rmp = &mproc[proc_nr]; + if ((rmp->mp_flags & (IN_USE | ZOMBIE)) != IN_USE) return; if ((rmp->mp_flags & ALARM_ON) == 0) return; rmp->mp_flags &= ~ALARM_ON; diff --git a/servers/pm/timers.c b/servers/pm/timers.c index c052b2909..13815a10b 100644 --- a/servers/pm/timers.c +++ b/servers/pm/timers.c @@ -14,23 +14,23 @@ PRIVATE timer_t *pm_timers = NULL; PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) { int r; - clock_t now, old_head = 0, new_head; + clock_t now, prev_time = 0, next_time; if((r = getuptime(&now)) != OK) panic(__FILE__, "PM couldn't get uptime from system task.", NO_NUM); - tmr_inittimer(tp); + /* Set timer argument. */ tmr_arg(tp)->ta_int = arg; - old_head = tmrs_settimer(&pm_timers, tp, now+ticks, watchdog, &new_head); + prev_time = tmrs_settimer(&pm_timers, tp, now+ticks, watchdog, &next_time); /* reschedule our synchronous alarm if necessary */ - if(! old_head || old_head > new_head) { - if(sys_syncalrm(SELF, new_head, 1) != OK) + if(! prev_time || prev_time > next_time) { + if(sys_syncalrm(SELF, next_time, 1) != OK) panic(__FILE__, "PM set timer couldn't set synchronous alarm.", NO_NUM); #if VERBOSE else - printf("timers: after setting, set synalarm to %d -> %d\n", old_head, new_head); + printf("timers: after setting, set synalarm to %d -> %d\n", prev_time, next_time); #endif } @@ -39,14 +39,14 @@ PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) PUBLIC void pm_expire_timers(clock_t now) { - clock_t new_head; - tmrs_exptimers(&pm_timers, now, &new_head); - if(new_head > 0) { - if(sys_syncalrm(SELF, new_head, 1) != OK) + clock_t next_time; + tmrs_exptimers(&pm_timers, now, &next_time); + if(next_time > 0) { + if(sys_syncalrm(SELF, next_time, 1) != OK) panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM); #if VERBOSE else - printf("timers: after expiry, set synalarm to %d\n", new_head); + printf("timers: after expiry, set synalarm to %d\n", next_time); #endif } #if VERBOSE @@ -56,19 +56,19 @@ PUBLIC void pm_expire_timers(clock_t now) PUBLIC void pm_cancel_timer(timer_t *tp) { - clock_t new_head, old_head; - old_head = tmrs_clrtimer(&pm_timers, tp, &new_head); + clock_t next_time, prev_time; + prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time); /* if the earliest timer has been removed, we have to set * the synalarm to the next timer, or cancel the synalarm - * altogether if th last time has been cancelled (new_head + * altogether if th last time has been cancelled (next_time * will be 0 then). */ - if(old_head < new_head || ! new_head) { - if(sys_syncalrm(SELF, new_head, 1) != OK) + if(prev_time < next_time || ! next_time) { + if(sys_syncalrm(SELF, next_time, 1) != OK) panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM); #if VERBOSE - printf("timers: after cancelling, set synalarm to %d -> %d\n", old_head, new_head); + printf("timers: after cancelling, set synalarm to %d -> %d\n", prev_time, next_time); #endif } #if VERBOSE