Recent

Author Topic: [SOLVED] TProcess — ppRealTime priority does not work  (Read 2328 times)

furious programming

  • Hero Member
  • *****
  • Posts: 853
[SOLVED] TProcess — ppRealTime priority does not work
« on: January 21, 2021, 06:44:19 pm »
I have a strange problem. My program uses one TProcess instance to run an external program (here: the FCEUX emulator). In addition to specifying the application path and the ROM file to open in the emulator, it also sets the priority to the highest possible, i.e. ppRealTime (it is required):

Code: Pascal  [Select][+][-]
  1. procedure TEmulator.InitProcess();
  2. begin
  3.   FProcess := TProcess.Create(nil);
  4.  
  5.   {$IFDEF REGION_PAL}
  6.   FProcess.Executable := 'emulator\pal\fceux64.exe';
  7.   FProcess.Parameters.Add('emulator\pal\games\Tetris (Europe).nes');
  8.   {$ELSE}
  9.   FProcess.Executable := 'emulator\ntsc\fceux64.exe';
  10.   FProcess.Parameters.Add('emulator\ntsc\games\Tetris (USA).nes');
  11.   {$ENDIF}
  12.  
  13.   FProcess.Priority := ppRealTime;
  14.   FProcess.Execute();
  15. end;

The emulator boots up correctly, but its process priority is set to High instead of Realtime (see attachment). My program (the one running the emulator) works with basic permissions, so does the emulator. System info and Lazarus version in signature.

Does anyone know why this is happening and how to fix it?
« Last Edit: January 23, 2021, 01:07:36 pm by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: TProcess — using ppRealTime priority does not work
« Reply #1 on: January 21, 2021, 07:25:13 pm »
By default, the SeIncreaseBasePriorityPrivilege privilege, which is required to set the realtime priority for processes, is disabled even for admins. It must be requested explicitly.

furious programming

  • Hero Member
  • *****
  • Posts: 853
Re: TProcess — using ppRealTime priority does not work
« Reply #2 on: January 23, 2021, 01:05:14 pm »
Ok, thank you very much for the information. I changed the execution level from asInvoker to requireAdministrator in the project settings window, and it now works fine. But the problem is that now I'm not able to run my application in debug mode (using IDE) — every time the debugger just crash. The solution is to run Lazarus as administrator, so I have to remember this. 8)
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: [SOLVED] TProcess — ppRealTime priority does not work
« Reply #3 on: January 26, 2021, 05:02:33 am »
You should be very careful with the RealTime priority.

https://devblogs.microsoft.com/oldnewthing/20100610-00/?p=13753
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

 

TinyPortal © 2005-2018