Re: Changing priority of threads from another application
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Wed, 3 May 2006 16:04:07 -0700
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. The handles
would only mean something in the context of the process that spawned the
threads. I see no way to address this other than via the third-parties in
question.
Paul T.
"Peter Stephens" <PeterStephens@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6F9A7C3E-671E-4390-A74A-F3153C25247B@xxxxxxxxxxxxxxxx
Hi Paul,
thanks for your reply. I think you are right, there may not be a way to
do
this, the threadIDs are pretty useless anyways when it comes to trying to
do
something with them.
Had a good long look around and the best I can get is the handle to the
process. From there, I could potentially read the process memory and
maybe
from there get an idea of what the thread handles are but I have no idea
what
they would look like or where to start looking for them... Perhaps I could
use the threadids that the toolhelp api calls return and search the
process
memory.......
Sigh.. Would be nice to be able to do it and be able to tune our platform
and the apps but I guess it would be a bit of a potential liability with
other apps coming in uninvited. Still it would be nice to be able to
solve
the problem we have by changing the priority of the offending apps. There
are several apps that we don't have access to source that we are trying to
get priorities to play nice.
Anyways, would still appreciate any comments on this and I'll post back if
I come up with anything useful myself.
cheers!
Peter
"Paul G. Tobey [eMVP]" wrote:
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
.
- References:
- Re: Changing priority of threads from another application
- From: Paul G. Tobey [eMVP]
- Re: Changing priority of threads from another application
- From: Peter Stephens
- Re: Changing priority of threads from another application
- Prev by Date: Re: Can I port eVC++ app for Win CE 4.2 to VS 2005?
- Next by Date: Send event to parent control in Csharp
- Previous by thread: Re: Changing priority of threads from another application
- Next by thread: Re: failed dll loading
- Index(es):
Relevant Pages
|