Geeks With Blogs
Thinking Kernel Mode ExAllocatePoolWithTag(KMScrapPad, sizeof(KMSCRAP), TAG_TKM);
New Page 1

Never allocate a dispatcher object from PagedPool. Which means, don't even think about doing a 

KSPIN_LOCK SpinLock;

within your PAGED_CODE. 

If a dispatcher object is allocated from PagedPool, the driver might work peacefully, but occasionally the system will bugcheck saying that it tried to access paged memory from higher IRQL.

So,

  1. Allocate them explicitly from NonPagedPool .

    PKSPIN_LOCK pSpinLock = ExAllocatePool(NonPagedPool, sizeof(struct KSPIN_LOCK));


  2. Or declare them globally. (All global variables in a kernel mode driver are allocated from NonPagedPool).

  3. You can place them in the device extension of the driver created device object. The device extension is always allocated from NonPaged memory.

  4. You can also place them in the controller extension of the driver created controller object.

 

Posted on Thursday, October 20, 2005 1:11 PM | Back to top


Comments on this post: Allocating a synchronization primitive

# re: Allocating a synchronization primitive
Requesting Gravatar...
Da could u present one on synchronisation primitives?
Left by Good paper on Oct 20, 2005 7:48 PM

Your comment:
 (will show your gravatar)


Copyright © Sreejith S | Powered by: GeeksWithBlogs.net