Tech Support > Microsoft Windows > Drivers > How to prevent context switching?
How to prevent context switching?
Posted by Nikhil on April 26th, 2005



Hi,

I am bit new to device driver programming. I would like to know how to
prevent context switching between threads.

Here is the scenario:

Thread A is running at PASSIVE LEVEL, driver gets into some funny state and
hence I want to panic the system so that I can get a memory dump to diaognise
the problem. So before crashing, I copy required data in a temporary buffer.
When I am about to panic the system, another thread B gets scheduled,
pre-empts the already running thread A, does context switching, runs for a
short burst and modifies data from my main buffer. Once thread B finishes,
thread A resumes the operation and panics the system. When I analyze memory
dump, I notice that contents in temp buffer and main buffer differ as thread
B modifies main buffer.

I want to know how do I prevent this context switching between threads A and
B? As soon as I get into funny state, I want to copy the data in temporary
buffer and crash the system.

Thanks.

Posted by Maxim S. Shatskih on April 26th, 2005


Raise to DISPATCH_LEVEL, this prevents context switching on this CPU.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Nikhil" <Nikhil@discussions.microsoft.com> wrote in message
news:6F6C56F3-21F0-422B-ADEF-FC892729DFD9@microsoft.com...


Posted by Nikhil on April 26th, 2005


Thank You, that helped.

"Maxim S. Shatskih" wrote:


Similar Posts