From cec14a334c28150c2237314534eb29b0d2853afb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Aug 2018 13:14:19 +0200 Subject: [PATCH] Document that wxThread::SetPriority() is broken under Unix The code setting thread priority doesn't work without changing the scheduling policy as thread priorities are simply ignored when using the default SCHED_OTHER (at least under Linux and NetBSD, but probably other systems too). See #18195. --- interface/wx/thread.h | 3 +++ src/unix/threadpsx.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/interface/wx/thread.h b/interface/wx/thread.h index e99caa1605..f308327a29 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -1248,6 +1248,9 @@ public: be only set after creating the thread with CreateThread(). But under all platforms this method can be called either before launching the thread using Run() or after doing it. + + Please note that currently this function is not implemented when using + the default (@c SCHED_OTHER) scheduling policy under POSIX systems. */ void SetPriority(unsigned int priority); diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 6611e5ece4..db797e696f 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -1005,6 +1005,12 @@ static bool SetThreadPriority(pthread_attr_t& attr, int prio) return false; } + // TODO: on most (all?) systems, thread priorities can't be used with + // SCHED_OTHER policy, so we need to check if this is the current + // policy and change it to something else (SCHED_FIFO or SCHED_RR?) + // in order to be able to actually change the priority as without + // doing it the code below just not going to work. + #ifdef __VMS__ /* the pthread.h contains too many spaces. This is a work-around */ # undef sched_get_priority_max