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.
This commit is contained in:
Jorrit Herder 2005-07-20 15:27:42 +00:00
parent c0718054e9
commit f1153541c7
7 changed files with 39 additions and 37 deletions

View file

@ -1,3 +0,0 @@
#include <timers.h>

View file

@ -15,6 +15,7 @@ struct super_block; /* proto.h needs to know this */
#include "fs.h" #include "fs.h"
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/ioc_memory.h> #include <sys/ioc_memory.h>
#include <sys/svrctl.h> #include <sys/svrctl.h>
@ -48,6 +49,7 @@ PUBLIC void main()
* three major activities: getting new work, processing the work, and sending * three major activities: getting new work, processing the work, and sending
* the reply. This loop never terminates as long as the file system runs. * the reply. This loop never terminates as long as the file system runs.
*/ */
sigset_t sigset;
int error; int error;
fs_init(); fs_init();
@ -60,18 +62,18 @@ PUBLIC void main()
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */ super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
/* Check for special control messages first. */ /* Check for special control messages first. */
#if DEAD_CODE if (call_nr == SYS_EVENT) {
if (call_nr == HARD_STOP) { sigset = m_in.NOTIFY_ARG;
do_sync(); if (sigismember(&sigset, SIGKSTOP)) {
sys_exit(0); /* never returns */ do_sync();
} else sys_exit(0); /* never returns */
#endif }
if(call_nr == SYN_ALARM) { } else if (call_nr == SYN_ALARM) {
/* Not a user request; system has expired one of our timers, /* Not a user request; system has expired one of our timers,
* currently only in use for select(). Check it. * currently only in use for select(). Check it.
*/ */
fs_expire_timers(m_in.NOTIFY_TIMESTAMP); 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. */ /* Device notify()s us of fd that has become usable. */
select_notified(&m_in); select_notified(&m_in);
} else { } else {

View file

@ -322,7 +322,7 @@ PUBLIC void privileges_dmp()
return; 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++) { for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue; if (isemptyp(rp)) continue;
@ -333,8 +333,8 @@ PUBLIC void privileges_dmp()
r = -1; r = -1;
for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++) for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++)
if (sp->s_proc_nr == rp->p_nr) { r ++; break; } if (sp->s_proc_nr == rp->p_nr) { r ++; break; }
if (r == -1) { if (r == -1 && ! (rp->p_rts_flags & SLOT_FREE)) {
printf("... warning, no privileges found!\n"); printf("... no privileges found, probaly a user process\n");
continue; continue;
} }
printf("(%02u) %-7.7s %3x %02.2u", printf("(%02u) %-7.7s %3x %02.2u",

View file

@ -57,12 +57,13 @@ PUBLIC void main(void)
case SYS_EVENT: case SYS_EVENT:
sigset = (sigset_t) m_in.NOTIFY_ARG; sigset = (sigset_t) m_in.NOTIFY_ARG;
if (sigismember(&sigset, SIGKMESS)) { if (sigismember(&sigset, SIGKMESS)) {
printf("IS proc SIGKMESS\n");
result = do_new_kmess(&m_in); result = do_new_kmess(&m_in);
} else if (sigismember(&sigset, SIGTERM)) { }
printf("IS proc SIGTERM\n"); if (sigismember(&sigset, SIGTERM)) {
} else { /* nothing to do on shutdown */
report("IS","warning, got unknown signal", NO_NUM); }
if (sigismember(&sigset, SIGKSTOP)) {
/* nothing to do on shutdown */
} }
continue; continue;
case DIAGNOSTICS: case DIAGNOSTICS:

View file

@ -176,8 +176,9 @@ PUBLIC int do_exec()
if (basename == NULL) basename = name; else basename++; if (basename == NULL) basename = name; else basename++;
strncpy(rmp->mp_name, basename, PROC_NAME_LEN-1); strncpy(rmp->mp_name, basename, PROC_NAME_LEN-1);
rmp->mp_name[PROC_NAME_LEN] = '\0'; 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); if (rmp->mp_flags & TRACED) check_sig(rmp->mp_pid, SIGTRAP);
return(SUSPEND); /* no reply, new program just runs */ return(SUSPEND); /* no reply, new program just runs */

View file

@ -355,6 +355,7 @@ struct timer *tp;
proc_nr = tmr_arg(tp)->ta_int; /* get process from timer */ proc_nr = tmr_arg(tp)->ta_int; /* get process from timer */
rmp = &mproc[proc_nr]; rmp = &mproc[proc_nr];
if ((rmp->mp_flags & (IN_USE | ZOMBIE)) != IN_USE) return; if ((rmp->mp_flags & (IN_USE | ZOMBIE)) != IN_USE) return;
if ((rmp->mp_flags & ALARM_ON) == 0) return; if ((rmp->mp_flags & ALARM_ON) == 0) return;
rmp->mp_flags &= ~ALARM_ON; rmp->mp_flags &= ~ALARM_ON;

View file

@ -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) PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{ {
int r; int r;
clock_t now, old_head = 0, new_head; clock_t now, prev_time = 0, next_time;
if((r = getuptime(&now)) != OK) if((r = getuptime(&now)) != OK)
panic(__FILE__, "PM couldn't get uptime from system task.", NO_NUM); panic(__FILE__, "PM couldn't get uptime from system task.", NO_NUM);
tmr_inittimer(tp); /* Set timer argument. */
tmr_arg(tp)->ta_int = arg; 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 */ /* reschedule our synchronous alarm if necessary */
if(! old_head || old_head > new_head) { if(! prev_time || prev_time > next_time) {
if(sys_syncalrm(SELF, new_head, 1) != OK) if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM set timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__, "PM set timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE #if VERBOSE
else 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 #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) PUBLIC void pm_expire_timers(clock_t now)
{ {
clock_t new_head; clock_t next_time;
tmrs_exptimers(&pm_timers, now, &new_head); tmrs_exptimers(&pm_timers, now, &next_time);
if(new_head > 0) { if(next_time > 0) {
if(sys_syncalrm(SELF, new_head, 1) != OK) if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE #if VERBOSE
else else
printf("timers: after expiry, set synalarm to %d\n", new_head); printf("timers: after expiry, set synalarm to %d\n", next_time);
#endif #endif
} }
#if VERBOSE #if VERBOSE
@ -56,19 +56,19 @@ PUBLIC void pm_expire_timers(clock_t now)
PUBLIC void pm_cancel_timer(timer_t *tp) PUBLIC void pm_cancel_timer(timer_t *tp)
{ {
clock_t new_head, old_head; clock_t next_time, prev_time;
old_head = tmrs_clrtimer(&pm_timers, tp, &new_head); prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time);
/* if the earliest timer has been removed, we have to set /* if the earliest timer has been removed, we have to set
* the synalarm to the next timer, or cancel the synalarm * 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). * will be 0 then).
*/ */
if(old_head < new_head || ! new_head) { if(prev_time < next_time || ! next_time) {
if(sys_syncalrm(SELF, new_head, 1) != OK) if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE #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 #endif
} }
#if VERBOSE #if VERBOSE