Click here to Skip to main content
15,797,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i started to learn about driver programming

i want to make my driver do a thing every 2000 ms for example

and in c++ i will be like this
Sleep(2000);//(2 Seconds)

the question is :
how to do like it in c driver
it must be like this
SleepFunction(2000);//Which doesnt exist
xXTariqoO 4-Aug-13 19:27pm    
i prefer to use it in new thread

The principle is exactly the same as creating delays in user mode. Sleep() has very limited value and you can use Google to find out why. Ultimately you need waitable timers.

(1) Create a kernel timer via KeInitializeTimer.

(2) Set the timer with KeSetTimerEx and use a period of 2s for example.

(3) Create a thread in your driver. In the thread, call KeWaitForSingleObject to wait on the timer.
See also:

After that refer to Google.
Share this answer
Also you can use KeDelayExcutionThread

Third parameter of this function is in 100 nano seconds(0.01 micro seconds)[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900