Tobias Langner
Tobias Langner

Reputation: 10808

Setting a single thread to real-time priority under windows

is it possible to set the priority of a single thread to real-time priority although the process does not run under real-time priority?

Upvotes: 2

Views: 5922

Answers (2)

Arno
Arno

Reputation: 5194

The windows scheduling priorities are describing the situation clearly. There is no thread priority called "real-time priority". The utmost priority a thread can obtain is THREAD_PRIORITY_TIME_CRITICAL. But this does not completely describe the threads base priority. This is also determined by the processes priority class. For almost all process priority classes the setting of THREAD_PRIORITY_TIME_CRITICAL will cause the thread to run in base priority of 15. One exception is the REALTIME_PRIORITY_CLASS. A thread set to THREAD_PRIORITY_TIME_CRITICAL within a process which is set to REALTIME_PRIORITY_CLASS runs at a base priority of 31, which is the highest priority to obtain.

The combination of NORMAL_PRIORITY_CLASS and THREAD_PRIORITY_TIME_CRITICAL puts a thread already well above most other threads (also OS) but I wouldn't call this real-time.

For my point of view (and as described in the "scheduling priorities list") real-time only starts at base priorities above 15. Therefore a thread can only obtain real-time priorties, when its process has REALTIME_PRIORITY_CLASS.

This means the correct answer to your question is NO. A thread cannot obtain real-priority when its process has no real-time priority.

Upvotes: 4

Deanna
Deanna

Reputation: 24263

It is possible using SetThreadPriority but it's not recommended.

Upvotes: 1

Related Questions