in reply to Set thread quantum for process under Windows

Type start /? on your command line for how to start a command with a low or background priory.

Hit ctrl-alt-del to bring up the task manager, right-clock the name on the processes tab and use "set Priority" ona running process.

See Win32::Process and use the appropriate constant from:

HIGH_PRIORITY_CLASS IDLE_PRIORITY_CLASS NORMAL_PRIORITY_CLASS REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL THREAD_PRIORITY_BELOW_NORMAL THREAD_PRIORITY_ERROR_RETURN THREAD_PRIORITY_HIGHEST THREAD_PRIORITY_IDLE THREAD_PRIORITY_LOWEST THREAD_PRIORITY_NORMAL THREAD_PRIORITY_TIME_CRITICAL ABOVE_NORMAL_PRIORITY_CLASS BELOW_NORMAL_PRIORITY_CLASS

if you are starting the process from within perl.

Personally, I find the first option the simplest even when starting a process from with a perl script:

system q[start /low notepad.exe];;

as it also allows me to set the affinity mask.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Set thread quantum for process under Windows
by chessgui (Scribe) on Jan 05, 2012 at 10:19 UTC
    Thanks a lot. These seem to be useful starting points. But my main goal is to do this on a constant basis (ie. not having to look my process up in the table manually every time rather do it automatically from the script) and having a look at the Win32::Process module it seems to me that if I open the process that way I won't have handles to the STDIN and STDOUT of the process, while if I open it through Open2 (as I do currently) there is not a Win32::Process object on which I can perform $ProcessObj->SetPriorityClass($class). There seems to be no method for creating a Win32::Process object from a pid.
      There seems to be no method for creating a Win32::Process object from a pid.

      Actually there is:

      Win32::Process::Open( $obj, $pid, $iflags );

      $pid is an existingprocess id as return by open2(), $obj is a variable you pass in which gets set to a Win32::Process object handle. You can the call ->SetPriority() on that. Eg.

      use Win32::Process;; $pid = system 1, 'notepad';; ## The return from open2 should work just + as well. Win32::Process::Open( $o, $pid, 0 );; print $o;; Win32::Process=SCALAR(0x4073208) $o->SetPriorityClass( IDLE_PRIORITY_CLASS );;

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        How could I have missed this?