Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Can a perl script on windows set it's self priority level?

by Eradicatore (Monk)
on Dec 19, 2007 at 17:37 UTC ( [id://657926]=perlquestion: print w/replies, xml ) Need Help??

Eradicatore has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to know if anyone knows a way inside a ActivePerl script on windows to find your own process id, and set the windows priority of that process.

Justin Eltoft

"If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

  • Comment on Can a perl script on windows set it's self priority level?

Replies are listed 'Best First'.
Re: Can a perl script on windows set it's self priority level?
by ikegami (Patriarch) on Dec 19, 2007 at 17:58 UTC

    Yes, SetPriorityClass in Win32::Process calls the system call with the same name.

    The code would look like

    use Win32::Process qw( HIGH_PRIORITY_CLASS ); Win32::Process::Open(my $proc, $$, 0) or die($^E); $proc->SetPriorityClass(HIGH_PRIORITY_CLASS) or die($^E);

    Update: Added parameter missing from call to Open, as mentioned in a reply.

      Awesome! Thanks! Note that I had to add one more parameter to the call to Win32::Process::Open(). For activestate, it takes "iflags" as third parameter.

      $iflags flag: inherit calling processes handles or not

      Justin Eltoft

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://657926]
Approved by sub_chick
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found