Many thanks for this excellent explanation ! I have the following code now to set the thread priority :-
$thispid = @ARGV[0];
$threadpriority = @ARGV[1];
use Win32::API;
$retcode = Win32::API->Import( 'Kernel32',
q[ BOOL SetThreadPriority( HANDLE hThread, int nPriority ) ] );
print "import set threadpriority = $retcode \n";
$retcode = SetThreadPriority( $thispid, $threadpriority );
print "set threadpriority = $retcode \n";
Value 1 is returned by Import, which I understand means OK. But value 0 is returned by SetThreadPriority. I tried using literals of 952 for the Handle of the thread I want to change and 0, 1, -1 for thread priority. Still no luck.
Am I using the wrong format for the parameters, or is the required Handle for the thread something else, not what I see in Task Manager as PID ? I think I haven't understood the relationship of Thread Handle to PID where there is only a single thread - If I use Win32::Process to dump all the process details, it shows 952 for Handle and ProcessId - is this the real internal picture or not ?
Is this the issue you were describing with "if you want a central thread to be able to adjust the priorities of other threads, then you will have to set up a mapping between threads->tids and Win32 Thread handles." - i.e. with my code example can I only change the thread priority of perl itself ?
thanks
Rod
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.