StallExecution() and Sleep() are two ways to add a delay to a driver. But they delay in different ways so be cautious when selecting one of them.
StallExecution() is a CEDDK function, so it is not easily accessible outside of Platform Builder. There is a good reason for that. StallExecution() takes as an argument the number of microseconds to delay. Since Windows CE uses a millisecond timer, there is no way to block for a number of microseconds. That means that StallExecution() must run continuously for the number of microseconds which can keep other threads from executing. That isn’t necessarily a problem with small numbers of microseconds, but as the number gets large this can create overall performance problems. The problem gets even worse if the thread that calls StallExecution() runs at a high priority.
Sleep() is available in Coredll and is available for outside of Platform Builder. Sleep() blocks for the number of milliseconds that are passed in. That means that when Sleep() is called other threads can start executing. Sleep() can also be called with zero milliseconds to request that the scheduler executes other threads at the same priority.
Copyright © 2009 – Bruce Eitman
All Rights Reserved