kernel mode thread creation and priority setting

kernel mode thread creation and priority setting

Post by Amit Vasud » Mon, 18 Aug 2003 13:08:28


i was experimenting with creating a kernel mode thread
and setting its priority to the maximum since i want the thread to get the
max time slice. i tried the following approach ---

1) used PsCreateSystemThread to create a thread in the system process

2) the driver init routine then waits for the thread to initialize and when
the thread has gotten its PKTHREAD variable after a call to
KeGetCurrentThread

3) the driver init routine then uses this PKTHREAD to set priority using
KeSetThreadPriority and the HIGHEST_PRIORITY flag.

well, this is what i did, but when i call KeSetThreadPriority my system
locks up :(. i want to know what i am doing wrong and would like a solution
so that my thread can run with the highest priority in the system getting
most of the time slice.

thanks
amit
 
 
 

kernel mode thread creation and priority setting

Post by Don Bur » Mon, 18 Aug 2003 22:20:01

Well you say the system locks up, what does your thread do after it gets the
highest_priority? If this is a uniprocessor, and you do not do something
to give up control you system will do as you describe.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting



when
solution

 
 
 

kernel mode thread creation and priority setting

Post by Amit Vasud » Mon, 18 Aug 2003 23:00:10

first of all an apology for creating a new post. seems like my outlook cant
reply to group in the existing post :((.

anyways,indeed, this is a uniprocessor, and my thread does nothing except
keep monitoring an area of memory in a while loop

while(running){
// my monitoring of some memory regions
}

and the variable running is set to false during driver unload, so that the
thread can terminate.

how do i relinquish control temporarily from my thread. is there a
kernel32!Sleep equivalent in kmode ?

thanks
amit




the


the
getting
 
 
 

kernel mode thread creation and priority setting

Post by David J. C » Mon, 18 Aug 2003 23:39:33

You want to set your thread to the highest priority possible so you can
sleep? Interesting concept!



cant


something


using
system
 
 
 

kernel mode thread creation and priority setting

Post by Amit Vasud » Tue, 19 Aug 2003 03:47:41

thnx don, i got it working used KeDelayExecutionThread. david, my thread
monitors a given region of memory for changes, but since its a very tight
loop, it was locking up in high priority. but with the small Delay, its
working fine.

thanks
amit