Recent

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

furious programming

  • Sr. Member
  • ****
  • Posts: 483
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
[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 2.0.10 with FPC 3.2.0 (SVN Revision 63526), Windows 10 — all 64-bit

ASerge

  • Hero Member
  • *****
  • Posts: 1736
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

  • Sr. Member
  • ****
  • Posts: 483
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
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 2.0.10 with FPC 3.2.0 (SVN Revision 63526), Windows 10 — all 64-bit

ASBzone

  • Hero Member
  • *****
  • Posts: 534
  • Automation leads to relaxation...
    • Free Console Utilities for Windows 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.0.11 r64280 / FPC v3.2.1-r48417 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 2009 (Build 19042)
Other Systems: Windows 10 Pro x64, Version 2009 (Build 19042) or greater

 

TinyPortal © 2005-2018