views:

1236

answers:

2

Hi all,

I am newbie in windows driver development. I just want to know , a global variable in a driver will use paged pool memory or non paged pool memory ?

Thanks and Regards

Navaneeth

A: 

Depends. The Non paged pool should be reserved for memory that must stay in RAM so if you are doing something critical that would affected by a memory page from disk operation then use non paged.

See here for more info.

Looking at this (though it discusses c++ as opposed to C) it would seem that by default the globals can be located in either by #pragma. Also on p22 of this we see how to do this. Finally this discuss here we see that the data segment should be non pagagable by default.

Preet Sangha
No.my question is somthing like if i declare a global variable in device driver,which memory will be used ,ie paged pool memory or non-paged pool memory?(Local variable will use non paged pool memory).
Navaneeth
it wont be depends.it will be either paged or non-paged pool.
Navaneeth
+2  A: 

Global variables in a kernel mode driver are allocated from NonPagedPool.

You can also use the device extension (when you call IoCreateDevice), it is always allocated from NonPaged memory.

I hope this helps, Martin

Martin