From: Christian Grothoff Date: Sat, 17 Apr 2010 17:45:48 +0000 (+0000) Subject: change process priority based on scheduling priority X-Git-Tag: initial-import-from-subversion-38251~22112 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ab8320d75c8563702b093edc139ab0652b282737;p=oweals%2Fgnunet.git change process priority based on scheduling priority --- diff --git a/TODO b/TODO index 6c9e18429..25e3ea0dd 100644 --- a/TODO +++ b/TODO @@ -1,27 +1,13 @@ 0.9.0pre1: * PEERINFO: - trust: need *fast* way to check/update trust in peers - (async peerinfo would not be right; certainly not with the - current API) + (async peerinfo would not be right; certainly not with the current API) +* STATISTICS: + - does not seem to work with timeouts (especially if service is not running) * UTIL: - - scheduler should change OS process priority based on task priority; - should make better use of task priorities in general - only connect() sockets that are ready (select()) [Nils] [On W32, we need to select after calling socket before doing connect etc.] -* SETUP: - - design & implement new setup tool -* TBENCH: [MW] - - good to have for transport/DV evaluation! -* DV: [Nate] - - write DV API (need to move declarations from dv_api.c to gnunet_dv_service.h!) - - implement DV service - - implement DV library (looks done) - - implement DV transport plugin - - implement testcases - - implement performance tests -* STATISTICS: - - does not seem to work with timeouts (especially if service is not running) * TOPOLOGY: - needs more testing (especially F2F topology) - needs to re-try connecting after disconnect (currently, it @@ -52,6 +38,9 @@ more balanced load) - check if new HELLO learned is different from old HELLO before resetting entire state! +* DATASTORE: + - API lacks cancellation methods (needed? or is disconnect enough?); + may also want to integrate request queuing here instead of gnunet-service-fs_drq.c * FS: [CG] - support recursive download even if filename is NULL and we hence do not generate files on disk (use temp_filename) @@ -71,18 +60,26 @@ - [gnunet-service-fs.c:700]: member 'ConnectedPeer::last_client_replies_woff' is never used - GAP improvements: + active reply route caching design & implementation of service; gap extension! -* DATASTORE: - - API lacks cancellation methods (needed? or is disconnect enough?); - may also want to integrate request queuing here instead of gnunet-service-fs_drq.c +* TBENCH: [MW] + - good to have for transport/DV evaluation! +* DV: [Nate] + - write DV API (need to move declarations from dv_api.c to gnunet_dv_service.h!) + - implement DV service + - implement DV library (looks done) + - implement DV transport plugin + - implement testcases + - implement performance tests * GNUNET-GTK: - use g_main_context_set_poll_func to integrate GTK with GNUnet Scheduler!? (YUCK!) - OR: add scheduler API to enable integration with GTK main loop instead of doing our own select - use g_main_context_pending, g_main_context_query / g_main_context_check / g_main_context_dispatch and NEVER g_main_loop_run (can this be done? might be the clean way to do this! But how - to integrate this with "tak_main"? Docu says: + to integrate this with "gtk_main"? Docu says: "It's OK to use the GLib main loop directly instead of gtk_main(), though it involves slightly more typing. See GMainLoop in the GLib documentation." => so maybe it "just works"? +* SETUP: + - design & implement new setup tool 0.9.0pre2: * TRACEKIT: [MW] diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 14aab8ce1..e57d11d63 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -62,6 +62,8 @@ GNUNET_OS_set_process_priority (pid_t proc, enum GNUNET_SCHEDULER_Priority prio) { int rprio = 0; + int have; + int delta; GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT); if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP) @@ -69,35 +71,39 @@ GNUNET_OS_set_process_priority (pid_t proc, /* convert to MINGW/Unix values */ switch (prio) { - case GNUNET_SCHEDULER_PRIORITY_DEFAULT: + case GNUNET_SCHEDULER_PRIORITY_UI: + case GNUNET_SCHEDULER_PRIORITY_URGENT: #ifdef MINGW - rprio = NORMAL_PRIORITY_CLASS; + rprio = HIGH_PRIORITY_CLASS; #else rprio = 0; #endif break; + case GNUNET_SCHEDULER_PRIORITY_HIGH: #ifdef MINGW rprio = ABOVE_NORMAL_PRIORITY_CLASS; #else - rprio = -5; + rprio = 5; #endif break; - case GNUNET_SCHEDULER_PRIORITY_BACKGROUND: + + case GNUNET_SCHEDULER_PRIORITY_DEFAULT: #ifdef MINGW - rprio = BELOW_NORMAL_PRIORITY_CLASS; + rprio = NORMAL_PRIORITY_CLASS; #else - rprio = 10; + rprio = 7; #endif break; - case GNUNET_SCHEDULER_PRIORITY_UI: - case GNUNET_SCHEDULER_PRIORITY_URGENT: + + case GNUNET_SCHEDULER_PRIORITY_BACKGROUND: #ifdef MINGW - rprio = HIGH_PRIORITY_CLASS; + rprio = BELOW_NORMAL_PRIORITY_CLASS; #else - rprio = -10; + rprio = 10; #endif break; + case GNUNET_SCHEDULER_PRIORITY_IDLE: #ifdef MINGW rprio = IDLE_PRIORITY_CLASS; @@ -113,10 +119,15 @@ GNUNET_OS_set_process_priority (pid_t proc, #ifdef MINGW SetPriorityClass (GetCurrentProcess (), rprio); #else - if (proc == getpid ()) + if ( (0 == proc) || + (proc == getpid () ) ) { + have = nice (0); + delta = rprio - have; errno = 0; - if ((-1 == nice (rprio)) && (errno != 0)) + if ( (rprio != 0) && + (-1 == nice (delta)) && + (errno != 0) ) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "nice"); diff --git a/src/util/scheduler.c b/src/util/scheduler.c index b5d998ef5..0e40d184d 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -25,6 +25,7 @@ */ #include "platform.h" #include "gnunet_common.h" +#include "gnunet_os_lib.h" #include "gnunet_scheduler_lib.h" #include "gnunet_signal_lib.h" #include "gnunet_time_lib.h" @@ -167,6 +168,11 @@ struct GNUNET_SCHEDULER_Handle */ enum GNUNET_SCHEDULER_Priority current_priority; + /** + * How 'nice' are we right now? + */ + int nice_level; + }; @@ -495,7 +501,11 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched) GNUNET_assert (pos != NULL); /* ready_count wrong? */ sched->ready[p] = pos->next; sched->ready_count--; - sched->current_priority = pos->priority; + if (sched->current_priority != pos->priority) + { + sched->current_priority = pos->priority; + GNUNET_OS_set_process_priority (0, pos->priority); + } sched->active_task = pos; tc.sched = sched; tc.reason = pos->reason; diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index 3b34beedf..d6cd623d2 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c @@ -103,7 +103,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { char *fn; const struct GNUNET_DISK_FileHandle *stdout_read_handle; - struct GNUNET_DISK_FileHandle *wh; + const struct GNUNET_DISK_FileHandle *wh; GNUNET_asprintf(&fn, "cat");