]> Zhao Yanbai Git Server - minix.git/commitdiff
Fixed bug in PM that caused update program not to be scheduled, so that
authorJorrit Herder <jnherder@minix3.org>
Wed, 20 Jul 2005 15:27:42 +0000 (15:27 +0000)
committerJorrit Herder <jnherder@minix3.org>
Wed, 20 Jul 2005 15:27:42 +0000 (15:27 +0000)
sync was not periodically run. Chain of timers was accidentially broken.

Kernel sends SIGKSTOP signal on shutdown. FS calls sync to clean up.

servers/fs/fs_timers.h [deleted file]
servers/fs/main.c
servers/is/dmp_kernel.c
servers/is/main.c
servers/pm/exec.c
servers/pm/signal.c
servers/pm/timers.c

diff --git a/servers/fs/fs_timers.h b/servers/fs/fs_timers.h
deleted file mode 100644 (file)
index b6c53eb..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include <timers.h>
-
index c10692238efc5bec3acb9fefb823b8b40a66be5f..fbac0851fb6249da2874394e372efb0e70de08a0 100644 (file)
@@ -15,6 +15,7 @@ struct super_block;           /* proto.h needs to know this */
 #include "fs.h"
 #include <fcntl.h>
 #include <string.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <sys/ioc_memory.h>
 #include <sys/svrctl.h>
@@ -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 {
index 56e9aefc9f2966da022747a2085aea359b12e5b5..ad41ed6059cf77d89f125ae118a34c1e26264132 100644 (file)
@@ -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",
index 0923f82517208472c3220c3aad1f78af07fd8a12..083fc52d55eb44db5c2eb5fd4941a64a7d563a72 100644 (file)
@@ -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:
index e675a426f33f7de9a2bdd192053a397c672d0b97..39021e82b97c4700945925600b6201dc8a947b1c 100644 (file)
@@ -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 */
index e1b874c708fc21f88b98ec91eea4fc6b6c913a93..18b3cef2c448131d4b94b2ca70f9f0b0eaf584db 100644 (file)
@@ -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;
index c052b29095df7997027deefcb082c89d540b9de3..13815a10b615fdd32b5b1f03f504a066e16c9ba4 100644 (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)
 {
        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