In my driver when i defined a static or a global variable, from which memory
pool is it allocated from ( paged or non-paged) ?
Ritesh N.
In my driver when i defined a static or a global variable, from which memory
pool is it allocated from ( paged or non-paged) ?
Ritesh N.
Depends which segment it is in. I believe the default is non-paged, and you
do have control over this. Look up “#pragma section” and “#pragma
alloc_text”. I believe the alloc_text pragma directive is the standard used
for NT device drivers.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ritesh Noronha
Sent: Thursday, April 22, 2004 12:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Static and Global Variables
In my driver when i defined a static or a global variable, from which memory
pool is it allocated from ( paged or non-paged) ?
Ritesh N.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@sublinear.org To unsubscribe
send a blank email to xxxxx@lists.osr.com
It’s probably not allocated from either pool. Globals and statics are
part of your driver image and are allocated differently than pool is by
the memory manager.
That said - it will depend on what data section is active when you
declare them. If you don’t mess with sections at all then it will be
non-paged.
Of course why in the world you’d use static variables in a shared,
reentrant block of code is another question. But that’s up to you.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ritesh Noronha
Sent: Wednesday, April 21, 2004 9:07 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Static and Global Variables
In my driver when i defined a static or a global variable, from which
memory pool is it allocated from ( paged or non-paged) ?
Ritesh N.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Nonpaged, unless you will use #pragma data_seg(“PAGE”)
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Ritesh Noronha”
To: “Windows System Software Devs Interest List”
Sent: Thursday, April 22, 2004 8:06 AM
Subject: [ntdev] Static and Global Variables
> In my driver when i defined a static or a global variable, from which memory
> pool is it allocated from ( paged or non-paged) ?
>
> Ritesh N.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
Perhaps I’m being a bit pedantic here, but global variables are not
allocated from “pool” (which is a special range of addresses within the
system address space and managed by the executive pool allocator.) They
are stored in the memory region of the driver (which is allocated and
set up when the I/O Manager calls MmLoadSystemImage).
There are numerous things that can change the paging policy of a driver
within its given memory region - try calling MmPageEntireDriver and see
what happens, for instance!
Max’s point, I believe, is only that by default, the memory within a
driver is all non-paged. But that policy can be changed either
statically (within the driver image) using pragma operations, or
dynamically using DDK functions. Neither of these have anything to do
with “pool” memory or “pool” allocation.
Like many things in the kernel environment we tend to “simplify” - like
the fact that we think of kernel stacks as being non-paged when in fact
MOST of the stacks in the kernel are pageable these days (all it takes
is a call to KeWaitForXxxObject with a UserMode wait - that tells the OS
that the kernel stack is safe to page out.)
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, April 22, 2004 6:47 AM
To: ntdev redirect
Subject: Re: [ntdev] Static and Global Variables
Nonpaged, unless you will use #pragma data_seg(“PAGE”)
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Ritesh Noronha”
To: “Windows System Software Devs Interest List”
Sent: Thursday, April 22, 2004 8:06 AM
Subject: [ntdev] Static and Global Variables
> In my driver when i defined a static or a global variable, from which
memory
> pool is it allocated from ( paged or non-paged) ?
>
> Ritesh N.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Related question: Are uninitialized global variables always zero? It seems
so, but is that guaranteed?
Thanks,
Ken
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Thursday, April 22, 2004 6:57 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Static and Global Variables
Perhaps I’m being a bit pedantic here, but global variables are not
allocated from “pool” (which is a special range of addresses within the
system address space and managed by the executive pool allocator.) They
are stored in the memory region of the driver (which is allocated and
set up when the I/O Manager calls MmLoadSystemImage).
There are numerous things that can change the paging policy of a driver
within its given memory region - try calling MmPageEntireDriver and see
what happens, for instance!
Max’s point, I believe, is only that by default, the memory within a
driver is all non-paged. But that policy can be changed either
statically (within the driver image) using pragma operations, or
dynamically using DDK functions. Neither of these have anything to do
with “pool” memory or “pool” allocation.
Like many things in the kernel environment we tend to “simplify” - like
the fact that we think of kernel stacks as being non-paged when in fact
MOST of the stacks in the kernel are pageable these days (all it takes
is a call to KeWaitForXxxObject with a UserMode wait - that tells the OS
that the kernel stack is safe to page out.)
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, April 22, 2004 6:47 AM
To: ntdev redirect
Subject: Re: [ntdev] Static and Global Variables
Nonpaged, unless you will use #pragma data_seg(“PAGE”)
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Ritesh Noronha”
To: “Windows System Software Devs Interest List”
Sent: Thursday, April 22, 2004 8:06 AM
Subject: [ntdev] Static and Global Variables
> In my driver when i defined a static or a global variable, from which
memory
> pool is it allocated from ( paged or non-paged) ?
>
> Ritesh N.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@comcast.net
To unsubscribe send a blank email to xxxxx@lists.osr.com
Actually, this is a C language requirement (now, if you have been at
this for TOO LONG you remember when it was NOT a C language requirement.
Think “Unix Version 6” timeframe…)
So, yes, uninitialized global variables for C and C++ code compiled
using the DDK or IFS Kit compiler are guaranteed to be zero. If you
choose to use some other compiler or some other language for your driver
(lisp? Smalltalk?) then your results may differ.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Thursday, April 22, 2004 8:10 AM
To: ntdev redirect
Subject: RE: [ntdev] Static and Global Variables
Related question: Are uninitialized global variables always zero? It
seems
so, but is that guaranteed?
Thanks,
Ken
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Thursday, April 22, 2004 6:57 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Static and Global Variables
Perhaps I’m being a bit pedantic here, but global variables are not
allocated from “pool” (which is a special range of addresses within the
system address space and managed by the executive pool allocator.) They
are stored in the memory region of the driver (which is allocated and
set up when the I/O Manager calls MmLoadSystemImage).
There are numerous things that can change the paging policy of a driver
within its given memory region - try calling MmPageEntireDriver and see
what happens, for instance!
Max’s point, I believe, is only that by default, the memory within a
driver is all non-paged. But that policy can be changed either
statically (within the driver image) using pragma operations, or
dynamically using DDK functions. Neither of these have anything to do
with “pool” memory or “pool” allocation.
Like many things in the kernel environment we tend to “simplify” - like
the fact that we think of kernel stacks as being non-paged when in fact
MOST of the stacks in the kernel are pageable these days (all it takes
is a call to KeWaitForXxxObject with a UserMode wait - that tells the OS
that the kernel stack is safe to page out.)
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, April 22, 2004 6:47 AM
To: ntdev redirect
Subject: Re: [ntdev] Static and Global Variables
Nonpaged, unless you will use #pragma data_seg(“PAGE”)
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Ritesh Noronha”
To: “Windows System Software Devs Interest List”
Sent: Thursday, April 22, 2004 8:06 AM
Subject: [ntdev] Static and Global Variables
> In my driver when i defined a static or a global variable, from which
memory
> pool is it allocated from ( paged or non-paged) ?
>
> Ritesh N.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@comcast.net
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com