exclusive access to memory RRS feed

  • Question

  • hi, i want my driver to have exclusive access to system memory. Without interference from other threads.
    Does windows implement such mechanizm? or its all about racing and % chance for BSoD?

    Ofc i ask about SMP, so irql has nothing to do with it.
    Monday, November 17, 2008 2:01 PM

All replies

  • Hi,


    I am not quite sure on your intentions, but as far as Windows is concerned, there is no global kernel lock or the like. So in general it is not possible to gain exclusive access on the entire system space.


    If you want to protect a certain portion of your driver allocated memory there are plenty of synchronization primitives you can use. For example KMUTEX or KSPIN_LOCK, depending on the requirements of your driver.


    If you want to ensure that you are the only thread running, you may indeed raise the IRQL. This is implicitly done when acquiring a spin lock on an uniprocessor system. On SMP systems, you may try issuing DPCs on the other processors, which can notify your driver when they are scheduled. If you also disable interrupts, you should be pretty sure being the only thread running. However, I am not sure, if this is a recommended scenario by MSFT.




    Friday, December 12, 2008 3:31 PM