Within my Delphi Linux application I like to set a thread priority to "tpTimeCritical". Unfortunately the priority value cannot be changed. Every value <> 0 throws a Runtime Error 217.
I found out that on Linux the policy has to be changed first (SCHED_FIFO or SCHED_RR). In sched.h I have the following values:
#define SCHED_NORMAL 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_BATCH 3
#define SCHED_IDLE 5
#define SCHED_DEADLINE 6
After the policy has been set correctly, the priority should be set to a value between 1 and 99. Unfortunately this does not work.
constructor TMyThread.Create;
begin
inherited Create(True);
Policy := 1;
Priority := 90;
end;
After my inquiry about this with Embarcadero (RSP-26280) it turned out to be a bug in the corresponding Linux thread implementation. The bug was fixed in June 2020 and the fix was included in the next official release (I think 10.4).