gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1602 - in GNUnet: contrib src/util


From: durner
Subject: [GNUnet-SVN] r1602 - in GNUnet: contrib src/util
Date: Thu, 4 Aug 2005 10:59:32 -0700 (PDT)

Author: durner
Date: 2005-08-04 10:59:27 -0700 (Thu, 04 Aug 2005)
New Revision: 1602

Modified:
   GNUnet/contrib/config-client.in
   GNUnet/contrib/config-daemon.in
   GNUnet/src/util/initialize.c
Log:
"auto nice"-feature

Modified: GNUnet/contrib/config-client.in
===================================================================
--- GNUnet/contrib/config-client.in     2005-08-04 16:21:38 UTC (rev 1601)
+++ GNUnet/contrib/config-client.in     2005-08-04 17:59:27 UTC (rev 1602)
@@ -55,6 +55,19 @@
                Where to write the messages? Leave the entry unspecified (as
                default) to make the clients print their messages to stderr.
                Default is unspecified (stderr).
+               
+       config PROCESS-PRIORITY
+       string "Process priority"
+       default "NORMAL"
+       depends on Meta::ADVANCED-CLIENT
+       help
+               At which priority should the client tools run? If you don't 
want the
+               client-tools to interfere with other applications, set this to
+               "BELOW NORMAL" or "IDLE".
+               Acceptable values are "NORMAL", "BELOW NORMAL", "ABOVE NORMAL", 
"HIGH",
+               "IDLE" and nice(1) increments (a numeric value between -20 and 
19, keep
+               in mind that values smaller than 0 require root privileges).
+               Default is "NORMAL".
 endmenu
 
 menu "Network options for the clients" "NETWORK"

Modified: GNUnet/contrib/config-daemon.in
===================================================================
--- GNUnet/contrib/config-daemon.in     2005-08-04 16:21:38 UTC (rev 1601)
+++ GNUnet/contrib/config-daemon.in     2005-08-04 17:59:27 UTC (rev 1602)
@@ -178,7 +178,7 @@
                Which applications should gnunetd support? Specify the name of 
the
                dynamic shared object (DSO) that implements the service in the
                gnunetd core here. Separate multiple modules with spaces.
-
+               
                Whenever this option is changed, you MUST run gnunet-update.
                
                Currently, the available applications are:
@@ -200,7 +200,7 @@
                to be loaded!
                
                Default: APPLICATIONS = "advertising fs getoption stats traffic"
-  
+
   config TRANSPORTS
   string "Which transport mechanisms are available?"
   default "udp tcp http nat"
@@ -225,6 +225,18 @@
                Choices are: "udp tcp udp6 tcp6 nat http smtp"
                Default: TRANSPORTS = "udp tcp http nat"
 
+       config PROCESS-PRIORITY
+       string "Process priority"
+       default "NORMAL"
+       depends on Meta::ADVANCED
+       help
+               At which priority should the GNUnet server run? If you don't 
want it
+               to interfere with other applications, set this to "BELOW 
NORMAL" or "IDLE".
+               Acceptable values are "NORMAL", "BELOW NORMAL", "ABOVE NORMAL", 
"HIGH",
+               "IDLE" and nice(1) increments (a numeric value between -20 and 
19, keep
+               in mind that values smaller than 0 require root privileges).
+               Default is "NORMAL".
+
 endmenu
 
 if Meta::ADVANCED      

Modified: GNUnet/src/util/initialize.c
===================================================================
--- GNUnet/src/util/initialize.c        2005-08-04 16:21:38 UTC (rev 1601)
+++ GNUnet/src/util/initialize.c        2005-08-04 17:59:27 UTC (rev 1602)
@@ -99,6 +99,76 @@
 void doneCron();
 
 /**
+ * Set our process priority
+ */
+void setProcessPrio() {
+       char *str;
+       int prio = 0;
+       
+       /* Get setting as string */
+       str = getConfigurationString(testConfigurationString("GNUNETD", 
"_MAGIC_", "YES") ?
+               "GNUNETD" : "GNUNET", "PROCESS-PRIORITY");
+       if (str) {
+               /* We support four levels (NORMAL, ABOVE NORMAL, BELOW NORMAL, 
HIGH and IDLE)
+                * and the usual numeric nice() increments */
+               if (stricmp(str, "NORMAL") == 0)
+#ifdef MINGW
+                       prio = NORMAL_PRIORITY_CLASS;
+#else
+                       prio = 0;
+#endif
+               else if (stricmp(str, "ABOVE NORMAL") == 0)
+#ifdef MINGW
+                       prio = ABOVE_NORMAL_PRIORITY_CLASS;
+#else
+                       prio = -10;
+#endif
+               else if (stricmp(str, "BELOW NORMAL") == 0)
+#ifdef MINGW
+                       prio = BELOW_NORMAL_PRIORITY_CLASS;
+#else
+                       prio = 10;
+#endif
+               else if (stricmp(str, "HIGH") == 0)
+#ifdef MINGW
+                       prio = HIGH_PRIORITY_CLASS;
+#else
+                       prio = -20;
+#endif
+               else if (stricmp(str, "IDLE") == 0)
+#ifdef MINGW
+                       prio = IDLE_PRIORITY_CLASS;
+#else
+                       prio = 19;
+#endif
+               else {
+                       prio = atoi(str);
+                       
+#ifdef MINGW
+                       /* Convert the nice increment to a priority class */
+                       if (prio == 0)
+                               prio = NORMAL_PRIORITY_CLASS;
+                       else if (prio > 0 && prio <= 10)
+                               prio = BELOW_NORMAL_PRIORITY_CLASS;
+                       else if (prio > 0)
+                               prio = IDLE_PRIORITY_CLASS;
+                       else if (prio < 0 && prio >= -10)
+                               prio = ABOVE_NORMAL_PRIORITY_CLASS;
+                       else if (prio < 0)
+                               prio = HIGH_PRIORITY_CLASS;
+#endif
+               }
+               
+               /* Set process priority */
+#ifdef MINGW
+               SetPriorityClass(GetCurrentProcess(), prio);
+#else
+               nice(prio);
+#endif
+       }
+}
+
+/**
  * Initialize the util library. Use argc, argv and the given parser
  * for processing command-line options <strong>after</strong> the
  * configuration module was initialized, but <strong>before</strong> logging
@@ -132,6 +202,7 @@
     if (SYSERR == parser(argc, argv))
       return SYSERR;
   readConfiguration();
+  setProcessPrio();
   initLogging();
   if (testConfigurationString("GNUNETD",
                              "_MAGIC_",





reply via email to

[Prev in Thread] Current Thread [Next in Thread]