]> Zhao Yanbai Git Server - minix.git/commitdiff
service utility can par cpu option in system.conf
authorTomas Hruby <tom@minix3.org>
Tue, 20 Jul 2010 07:27:45 +0000 (07:27 +0000)
committerTomas Hruby <tom@minix3.org>
Tue, 20 Jul 2010 07:27:45 +0000 (07:27 +0000)
- does not have any effect, solely for debugging SMP

- backward compatible with older RS instance

commands/service/service.c
include/minix/config.h
include/minix/priv.h
include/minix/rs.h

index 1ad832642caa8212bf4278d5896f06e9b6d56ff6..9848548b8ca721c6710f2fb59e056e3e2e5630e5 100644 (file)
@@ -412,6 +412,7 @@ PRIVATE void fatal(char *fmt, ...)
 #define KW_SCHEDULER   "scheduler"
 #define KW_PRIORITY    "priority"
 #define KW_QUANTUM     "quantum"
+#define KW_CPU         "cpu"
 #define KW_IRQ         "irq"
 #define KW_IO          "io"
 #define KW_PCI         "pci"
@@ -649,7 +650,7 @@ PRIVATE void do_priority(config_t *cpe)
                fatal("do_priority: priority %d out of range at %s:%d",
                        priority_val, cpe->file, cpe->line);
        }
-       rs_start.rss_priority= (unsigned) priority_val;
+       rs_start.rss_priority= priority_val;
 }
 
 PRIVATE void do_quantum(config_t *cpe)
@@ -687,7 +688,45 @@ PRIVATE void do_quantum(config_t *cpe)
                fatal("do_quantum: quantum %d out of range at %s:%d",
                        quantum_val, cpe->file, cpe->line);
        }
-       rs_start.rss_quantum= (unsigned) quantum_val;
+       rs_start.rss_quantum= quantum_val;
+}
+
+PRIVATE void do_cpu(config_t *cpe)
+{
+       int cpu;
+       char *check;
+
+       /* Process a quantum value */
+       if (cpe->next != NULL)
+       {
+               fatal("do_cpu: just one value expected at %s:%d",
+                       cpe->file, cpe->line);
+       }       
+       
+
+       if (cpe->flags & CFG_SUBLIST)
+       {
+               fatal("do_cpu: unexpected sublist at %s:%d",
+                       cpe->file, cpe->line);
+       }
+       if (cpe->flags & CFG_STRING)
+       {
+               fatal("do_cpu: unexpected string at %s:%d",
+                       cpe->file, cpe->line);
+       }
+       cpu= strtol(cpe->word, &check, 0);
+       if (check[0] != '\0')
+       {
+               fatal("do_cpu: bad value '%s' at %s:%d",
+                       cpe->word, cpe->file, cpe->line);
+       }
+
+       if (cpu <= 0)
+       {
+               fatal("do_cpu: %d out of range at %s:%d",
+                       cpu, cpe->file, cpe->line);
+       }
+       rs_start.rss_cpu= cpu;
 }
 
 PRIVATE void do_irq(config_t *cpe)
@@ -1261,6 +1300,11 @@ PRIVATE void do_service(config_t *cpe, config_t *config)
                        do_quantum(cpe->next);
                        continue;
                }
+               if (strcmp(cpe->word, KW_CPU) == 0)
+               {
+                       do_cpu(cpe->next);
+                       continue;
+               }
                if (strcmp(cpe->word, KW_IRQ) == 0)
                {
                        do_irq(cpe->next);
@@ -1417,6 +1461,7 @@ PUBLIC int main(int argc, char **argv)
       rs_start.rss_scheduler= DSRV_SCH;
       rs_start.rss_priority= DSRV_Q;
       rs_start.rss_quantum= DSRV_QT;
+      rs_start.rss_cpu = DSRV_CPU;
 
       if (req_config) {
        assert(progname);
index 1e78739e563bb296516cf841b776e4b5d2e48c69..b67506ba0f7ddf70fd2a05e8b6454b5fab5bca0c 100644 (file)
 /* default scheduling quanta */
 #define USER_QUANTUM 200
 
+/* defualt user process cpu */
+#define USER_DEFAULT_CPU       -1 /* use the default cpu or do not change the
+                                     current one */
+
 /*===========================================================================*
  *     There are no user-settable parameters after this line                *
  *===========================================================================*/
index 70052d5136e78f2544121628f8980493a9428fda..07fe1a5e8750b8c0d6f822b09fcdd5e7c7b21ae7 100644 (file)
@@ -89,4 +89,7 @@
 #define DSRV_QT   USER_QUANTUM                     /* dynamic system services */
 #define USR_QT    USER_QUANTUM                     /* user processes */
 
+/* default CPU */
+#define DSRV_CPU USER_DEFAULT_CPU
+
 #endif /* _MINIX_PRIV_H */
index d221cbdc616b6e5012b4d3fa6acc521affcd6a33..997f31cce8df7ae53091ed3870df4c1f20a3df7a 100644 (file)
@@ -71,6 +71,14 @@ struct rs_start
        bitchunk_t rss_vm[VM_CALL_MASK_SIZE];
        int rss_nr_control;
        struct rss_label rss_control[RS_NR_CONTROL];
+
+       /*
+        * SMP specific data
+        *
+        * must be at the end of the structure for binary compatibility with
+        * non-smp sysytems
+        */
+       int rss_cpu;
 };
 
 /* ACL information for access to PCI devices */