Look at ZwSetInformationThread to do this in general. But you really
should be looking at your algorithm and why such a delay is such a problem
for you.
Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, March 07, 2017 9:59 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Using KeSetPriorityThread() on user threads
I have some code that needs to run at PASSIVE_LEVEL (or APC_LEVEL), but it
is indirectly delaying a DPC - i.e. while this code runs, a DPC may not be
able to finish a task and will reschedule itself later.
This doesn’t seem to be a big deal usually, but sometimes when the CPU load
is high, my passive thread gets preempted, and now my DPC is at the mercy of
the scheduler. That’s… less than ideal.
In the typical case, I’d use KeSetPriorityThread() on the passive thread to
make sure it doesn’t get indefinitely preempted by other passive threads.
However, per MSDN:
KPRIORITY KeSetPriorityThread(
Inout PKTHREAD Thread,
In KPRIORITY Priority
);
Thread [in, out] Pointer to the driver-created thread.
“driver-created thread”
Does this mean calling that on a user thread that entered kernelmode through
e.g. DeviceIoControl() is not valid? What about system workitem thread pool?
If that’s the case, is there some universal way to prevent passive threads
from being scheduled out in favor of other passive threads, except when
explicitly making a blocking call, such as accessing paged memory? Raising
the IRQL isn’t really an option here.
Thanks!
Milo
—
NTDEV is sponsored by OSR
Visit the list online at:
http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>