Calling KeSetPriorityThread from outside the thread

Hello,

In most examples I saw, the usage of KeSetPriorityThread is in the start
of the thread function.

However, we have a generic thread ‘starter’ which start threads, so I
was wondering if the starter can set the priority.

The code will look something like that:

Thread_starter ()

{

PsCreateSystemThread…

ObReferenceObjectByHandle…

KeSetPriorityThread

}

Since the thread starts when we call PsCreateSystemThread I am actually
changing its priority while it started running. Is this legal ?

Thanks.

xxxxx@emc.com wrote:

In most examples I saw, the usage of KeSetPriorityThread is in the
start of the thread function.

However, we have a generic thread ‘starter’ which start threads, so I
was wondering if the starter can set the priority.

The code will look something like that:

Thread_starter ()

{

PsCreateSystemThread…

ObReferenceObjectByHandle…

KeSetPriorityThread

}

Since the thread starts when we call PsCreateSystemThread I am
actually changing its priority while it started running. Is this legal ?

No problem at all. It’s common for a thread to set it’s own priority,
but what you have there is perfectly legal.

Now, you can’t predict how much work the thread has already done by the
time you change it’s priority, but as long as you’re aware of that, go
for it.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Excellent, thanks !

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, June 30, 2010 1:08 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Calling KeSetPriorityThread from outside the thread

xxxxx@emc.com wrote:

In most examples I saw, the usage of KeSetPriorityThread is in the
start of the thread function.

However, we have a generic thread ‘starter’ which start threads, so I
was wondering if the starter can set the priority.

The code will look something like that:

Thread_starter ()

{

PsCreateSystemThread…

ObReferenceObjectByHandle…

KeSetPriorityThread

}

Since the thread starts when we call PsCreateSystemThread I am
actually changing its priority while it started running. Is this legal
?

No problem at all. It’s common for a thread to set it’s own priority,
but what you have there is perfectly legal.

Now, you can’t predict how much work the thread has already done by the
time you change it’s priority, but as long as you’re aware of that, go
for it.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer