OSDN Git Service

Decrease worker thread priority.
authorLoRd_MuldeR <mulder2@gmx.de>
Wed, 12 Jul 2017 19:20:37 +0000 (21:20 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Wed, 12 Jul 2017 19:20:37 +0000 (21:20 +0200)
tools/GenTables/include/thread_utils.h
tools/GenTables/src/gen_table_xor.c

index 85d369a..6224ac9 100644 (file)
@@ -45,6 +45,16 @@ static inline void PTHREAD_JOIN(const pthread_t thread, void **const value_ptr)
        }
 }
 
+static inline void PTHREAD_SET_PRIORITY(const pthread_t thread, const int priority)
+{
+       struct sched_param params;
+       params.sched_priority = priority;
+       if (pthread_setschedparam(thread, SCHED_OTHER, &params))
+       {
+               crit_exit("FATAL: PThread internal error!");
+       }
+}
+
 static inline void MUTEX_INIT(pthread_mutex_t *const mtx)
 {
        if (pthread_mutex_init(mtx, NULL))
index 6c3a209..7feda8e 100644 (file)
@@ -568,6 +568,7 @@ int wmain(int argc, wchar_t *argv[])
                        thread_data[t].mutex = &stop_mutex;
                        thread_data[t].rand = &thread_rand[t];
                        PTHREAD_CREATE(&thread_id[t], NULL, thread_main, &thread_data[t]);
+                       PTHREAD_SET_PRIORITY(thread_id[t], -2);
                }
 
                for (size_t t = 0; t < THREAD_COUNT; t++)