Re: Changing priority of threads from another application

Tech-Archive recommends: Fix windows errors by optimizing your registry



I believe that those handles are process-specific, and I'm not 100% sure
that just casting an ID to a handle is going to work, either, but even if it
does give the right value, I think that the value is specific to the process
the thread is running in. So, since you're in another process context and
your handle table doesn't include those thread handles, they look invalid to
the call.

I think that the right way to approach this problem is to adjust priorities
only of those items that you own. So, if the third-party applications are
eating too many cycles, increase the priority of your own threads and yield
enough to allow the other applications to do some work, but only as much as
you're willing to allow.

Paul T.

"Peter Stephens" <PeterStephens@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85CC7AE9-66B5-4D0F-A0C6-3253E5C77B3C@xxxxxxxxxxxxxxxx
Hi All,

we are building an industrial controller and need to get the balance of
priorities on the controler right. We are running some applications that
are
from 3rd parties and don't have access to the source for these apps.
Unfortunately these apps are pretty greedy and are preventing the system
from
running correctly.

I would like to change the priority of one of these apps and all its
threads (it launches about 21 threads).

I thought I'd do this by geting the thread ID using the ToolHelp
Functions. I am able to get the THREADENTRY32 structures properly
populated
and can see the thread IDs.

Unfortunately when I try calling either

CeSetThreadPriority(myHandle, priToSet) or
SetThreadPriority(myHandle, priToSet)

where myHandle is set from the structure as follows

myHandle = (HANDLE)myTStruct.th32ThreadID;

I get an error code 6, meaning invalid handle. Am I doing something wrong
or is this not possible?

Are there any other ways to get a valid handle to threads to set their
priority from outside the process that created the thread?

Thanks for your help



.



Relevant Pages

  • Re: Changing priority of threads from another application
    ... other apps coming in uninvited. ... the problem we have by changing the priority of the offending apps. ... if the third-party applications are ... where myHandle is set from the structure as follows ...
    (microsoft.public.windowsce.app.development)
  • Re: How do I get a non-root process to be able to change scheduling policy?
    ... have this SCHED_FIFO response more 'fast' than others. ... These are applications where timing is ... part of the purpose of the application. ... does not dynamically adjust the priority based on behavior. ...
    (comp.os.linux.development.system)
  • Re: Changing priority of threads from another application
    ... Even if you got handle values, they would be useless, since you wouldn't be ... in the right context when your program tried to change them. ... other apps coming in uninvited. ... the problem we have by changing the priority of the offending apps. ...
    (microsoft.public.windowsce.app.development)
  • Re: How do I get a non-root process to be able to change scheduling policy?
    ... have "real time" requirements. ... These are applications where timing is ... part of the purpose of the application. ... does not dynamically adjust the priority based on behavior. ...
    (comp.os.linux.development.system)
  • Re: Xterm Hangs - Possible scheduler defect?
    ... >> Stupid applications can starve other applications for a while, ... its priority" I missed the "for its priority" part. ... his and all the waiters on it, until it releases his mutex, where he regains ...
    (Linux-Kernel)