I've discovered that the exported values for the various THREAD_PRIORITY_ disagree with the values my C acquaintance gave me. The values exported by Win32::Process are :
THREAD_PRIORITY_HIGHEST -1
THREAD_PRIORITY_ABOVE_NORMAL null
THREAD_PRIORITY_NORMAL -2
THREAD_PRIORITY_BELOW_NORMAL 1
THREAD_PRIORITY_IDLE 2147483647
THREAD_PRIORITY_LOWEST -15
The values my C acquaintance gave me are :-
Description Process priority Thread Priority
Realtime 256 15
High 128 2
Above normal 32768 1
Normal 32 0
Below normal 16384 -1
Idle 64 -2
Lowest n/a -15
I use the following code :-
$returncode=Win32::Process::Open($obj,$pid,0);
print "\n $returncode \n";
$returncode=$obj->SetPriorityClass(THREAD_PRIORITY_LOWEST);
print "\n $returncode \n";
It returns code 0 (failure) for HIGHEST and NORMAL, 1 (OK) for BELOW, IDLE, LOWEST, but does not in fact set the Thread Priority. In fact it will only set Process Priority, and only when I give it correct values as detailed above. E.g.
$returncode=$obj->SetPriorityClass(32);
sets Process Priority to normal as it should.
Conclusion : SetPriority does not seem able to set Thread Priority. Or am I missing something ? How do I tell it that it's a Thread Priority I'm trying to change rather than a Process Priority ? Why would the Pod text describe Thread Priority values if the routine won't use them ? |