Hello,
I’m new to driver development and I wonder what is the difference between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
Hello,
I’m new to driver development and I wonder what is the difference between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
> I’m new to driver development and I wonder what is the difference
between
paged and non paged memory and
Nonpaged memory will never be outswapped, while the paged memory can
be. So, the code accessing pageable memory must execute only in the
context where page faults can be resolved (< DISPATCH_LEVEL).
what is the need to use physical memory
rather than virtual memory.
For DMA only. Just forget about MmGetPhysicalAddress and
MmAllocateContiguousMemory calls. They are for very special uses only,
the common drivers must use the DMA adapter methods or macros like
HalAllocateCommonBuffer which wrap them around.
Max
Hi
I was also new, a few days ago, but I have already learned quite a lot
from Walter Oney’s book on WDM drivers. I can really recommend his
book: Programming the Windows Driver Model.
I will try to explain briefly off-hand but you will understand better
from the explanations in the book.
Paged memory originates from the idea that the processor has more
memory available to itself than the DRAM etc provides (virtual
memory). Memory blocks (pages) are being swapped from fast memory to
hard disk and back via structured layers of progressively slower (and
cheaper) memory using a caching mechanism. (First the processor’s
internal registers, then the cache, then DRAM, then Disk for
instance). The caching mechanism optimises Temporal and Spatial
locality aspects inherent in memory access. Paged memory can be
swapped at virtually any time. In certain circumstances you might
want to use non-paged memory because it is not swapped out.
I do not know why or how you will use physical memory rather than
virtual memory. The 386 based protected mode model does address
translation etc for you and gives you the advantage of protecting
application memory from being accessed by other applications on the
hardware level - a page fault (interrupt) is generated if this happens
etc etc. My understanding is that the NT Kernel api screens most of
the memory addressing detail from you (eg: address translation tables
etc).
Another good reference on virtual memory and paging is the (now old)
PC intern (systems programming) - only the chapter on Protected mode -
chapter 33 if you have access to it. Karen Hazzah’s book, only
chapter 2, 3 and 4, is also a good reference (Writing VxDs and Device
Drivers).
(This is just my understanding and the purpose is to help you get
going - I might be inaccurate on some points - do not use this
information as reference or fact)
-----Original Message-----
From: nunch [mailto:xxxxx@free.fr]
Sent: 14 March 2003 10:14
To: NT Developers Interest List
Subject: [ntdev] Paged and non paged memory
Hello,
I’m new to driver development and I wonder what is the difference
between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
You are currently subscribed to ntdev as: xxxxx@telkom.co.za
To unsubscribe send a blank email to xxxxx@lists.osr.com
paged and nonpaged memory are both virtual memory. paged memory is
relatively cheap to consume, but you cannot access it at raised IRQL
levels (>= DISPATCH_LEVEL.) nonpaged memory is relatively expensive to
consume, but can be accessed at any IRQL level.
The default approach when writing a device driver is to use nonpaged
memory allocations until you have a compelling reason to use paged
memory.
Drivers never use physical memory directly. All access to memory in a
driver is virtual. However peripheral devices that need to read or write
system memory do so using physical addresses supplied by thier
controlling drivers. Drivers use physical memory address to program dma
operations on their devices.
===========================
Mark Roddy
Consultant, Microsoft DDK MVP
Hollis Technology Solutions
xxxxx@hollistech.com
www.hollistech.com
603-321-1032
-----Original Message-----
From: “nunch”
To: “NT Developers Interest List”
Date: Fri, 14 Mar 2003 03:13:36 -0500
Subject: [ntdev] Paged and non paged memory
> Hello,
>
> I’m new to driver development and I wonder what is the difference
> between
> paged and non paged memory and what is the need to use physical memory
> rather than virtual memory.
>
> Thanks for your answers!
>
> —
> You are currently subscribed to ntdev as: xxxxx@hollistech.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
Physical memory exists.
Virtual memory isn’t really memory, but rather a mapping of processor virtual addresses to page table entries.
Page tables are a mechanism used by the processor and os to manage the mapping of virtual memory address ranges to either physical memory or disk (i.e. the swap device). Those virtual addresses that do not map to physical memory are either invalid (i.e. no mapping) or swapped out (i.e. on disk).
Paged memory is a portion of physical memory that is used to dynamically map virtual memory address ranges. Thus, paged memory may represent different virtual memory address ranges for the same or different process over time. The mapping of virtual addreses to paged memory and/or disk blocks is controlled by the memory manager algorithms in the os.
Non-paged memory is a portion of physical memory that is reserved by the OS to not being under a paging policy. That is, the contents of these physical memory blocks will not be subject to swapping to and from disk by the memory manager.
Pinned or locked memory usually refers to Paged memory that is temporarily excluded from being swapped. Typically memory is locked down when the contents are undergoing some IO operation (disk or network), and thus the memory is locked so that the contents of the physical memory isn’t modified by the memory manager while the contents are being accessed by the IO h/w.
Usually the os has partitioned its virtual address space into the following ranges:
Duane.
-----Original Message-----
From: nunch [mailto:xxxxx@free.fr]
Sent: Friday, March 14, 2003 3:14 AM
To: NT Developers Interest List
Subject: [ntdev] Paged and non paged memory
Hello,
I’m new to driver development and I wonder what is the difference between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Guys,
Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
SPECE??(high 2GB of virtual address) or does user virtual address space also
has non paged pool???
----- Original Message -----
From: “McCrory, Duane”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 7:35 AM
Subject: [ntdev] RE: Paged and non paged memory
Physical memory exists.
Virtual memory isn’t really memory, but rather a mapping of processor
virtual addresses to page table entries.
Page tables are a mechanism used by the processor and os to manage the
mapping of virtual memory address ranges to either physical memory or disk
(i.e. the swap device). Those virtual addresses that do not map to physical
memory are either invalid (i.e. no mapping) or swapped out (i.e. on disk).
Paged memory is a portion of physical memory that is used to dynamically map
virtual memory address ranges. Thus, paged memory may represent different
virtual memory address ranges for the same or different process over time.
The mapping of virtual addreses to paged memory and/or disk blocks is
controlled by the memory manager algorithms in the os.
Non-paged memory is a portion of physical memory that is reserved by the OS
to not being under a paging policy. That is, the contents of these physical
memory blocks will not be subject to swapping to and from disk by the memory
manager.
Pinned or locked memory usually refers to Paged memory that is temporarily
excluded from being swapped. Typically memory is locked down when the
contents are undergoing some IO operation (disk or network), and thus the
memory is locked so that the contents of the physical memory isn’t modified
by the memory manager while the contents are being accessed by the IO h/w.
Usually the os has partitioned its virtual address space into the following
ranges:
1) Pageable memory
2) Non-pageable memory
3) Memory mapped device memory (i.e. PCI device memory)
Duane.
-----Original Message-----
From: nunch [mailto:xxxxx@free.fr]
Sent: Friday, March 14, 2003 3:14 AM
To: NT Developers Interest List
Subject: [ntdev] Paged and non paged memory
Hello,
I’m new to driver development and I wonder what is the difference between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
—
You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@hotmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Pool is simply a way of managing kernel memory allocations - like heaps
in user-mode. The fact that one of the pools is from paged memory and
the other from non-paged memory is irrelvant - they’re both kernel
memory allocators. As such they only supply kernel memory.
Drivers can lock down the user address space by building an MDL for the
region in question and calling MmProbeAndLockPages. So any memory could
be locked, regardless of whether it’s from “pool” or not.
-p
-----Original Message-----
From: sankar [mailto:xxxxx@hotmail.com]
Sent: Friday, March 14, 2003 10:28 AM
To: NT Developers Interest List
Guys,
Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
SPECE??(high 2GB of virtual address) or does user virtual address space
also has non paged pool???
----- Original Message -----
From: “McCrory, Duane”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 7:35 AM
Subject: [ntdev] RE: Paged and non paged memory
Physical memory exists.
Virtual memory isn’t really memory, but rather a mapping of processor
virtual addresses to page table entries.
Page tables are a mechanism used by the processor and os to manage the
mapping of virtual memory address ranges to either physical memory or
disk (i.e. the swap device). Those virtual addresses that do not map to
physical memory are either invalid (i.e. no mapping) or swapped out
(i.e. on disk).
Paged memory is a portion of physical memory that is used to dynamically
map virtual memory address ranges. Thus, paged memory may represent
different virtual memory address ranges for the same or different
process over time.
The mapping of virtual addreses to paged memory and/or disk blocks is
controlled by the memory manager algorithms in the os.
Non-paged memory is a portion of physical memory that is reserved by the
OS to not being under a paging policy. That is, the contents of these
physical memory blocks will not be subject to swapping to and from disk
by the memory manager.
Pinned or locked memory usually refers to Paged memory that is
temporarily excluded from being swapped. Typically memory is locked down
when the contents are undergoing some IO operation (disk or network),
and thus the memory is locked so that the contents of the physical
memory isn’t modified by the memory manager while the contents are being
accessed by the IO h/w.
Usually the os has partitioned its virtual address space into the
following
ranges:
1) Pageable memory
2) Non-pageable memory
3) Memory mapped device memory (i.e. PCI device memory)
Duane.
-----Original Message-----
From: nunch [mailto:xxxxx@free.fr]
Sent: Friday, March 14, 2003 3:14 AM
To: NT Developers Interest List
Subject: [ntdev] Paged and non paged memory
Hello,
I’m new to driver development and I wonder what is the difference
between paged and non paged memory and what is the need to use physical
memory rather than virtual memory.
Thanks for your answers!
—
You are currently subscribed to ntdev as: xxxxx@infiniconsys.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@hotmail.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
User address space doesn’t explicitly have any non paged pool, essentially it is all paged.
However, a driver can map non-paged kernel memory (and memory mapped device memory) into the address space of a process.
Duane.
-----Original Message-----
From: sankar [mailto:xxxxx@hotmail.com]
Sent: Friday, March 14, 2003 1:28 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Paged and non paged memory
Guys,
Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
SPECE??(high 2GB of virtual address) or does user virtual address space also
has non paged pool???
----- Original Message -----
From: “McCrory, Duane”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 7:35 AM
Subject: [ntdev] RE: Paged and non paged memory
Physical memory exists.
Virtual memory isn’t really memory, but rather a mapping of processor
virtual addresses to page table entries.
Page tables are a mechanism used by the processor and os to manage the
mapping of virtual memory address ranges to either physical memory or disk
(i.e. the swap device). Those virtual addresses that do not map to physical
memory are either invalid (i.e. no mapping) or swapped out (i.e. on disk).
Paged memory is a portion of physical memory that is used to dynamically map
virtual memory address ranges. Thus, paged memory may represent different
virtual memory address ranges for the same or different process over time.
The mapping of virtual addreses to paged memory and/or disk blocks is
controlled by the memory manager algorithms in the os.
Non-paged memory is a portion of physical memory that is reserved by the OS
to not being under a paging policy. That is, the contents of these physical
memory blocks will not be subject to swapping to and from disk by the memory
manager.
Pinned or locked memory usually refers to Paged memory that is temporarily
excluded from being swapped. Typically memory is locked down when the
contents are undergoing some IO operation (disk or network), and thus the
memory is locked so that the contents of the physical memory isn’t modified
by the memory manager while the contents are being accessed by the IO h/w.
Usually the os has partitioned its virtual address space into the following
ranges:
1) Pageable memory
2) Non-pageable memory
3) Memory mapped device memory (i.e. PCI device memory)
Duane.
-----Original Message-----
From: nunch [mailto:xxxxx@free.fr]
Sent: Friday, March 14, 2003 3:14 AM
To: NT Developers Interest List
Subject: [ntdev] Paged and non paged memory
Hello,
I’m new to driver development and I wonder what is the difference between
paged and non paged memory and what is the need to use physical memory
rather than virtual memory.
Thanks for your answers!
—
You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@hotmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
No, nonpaged pool is kernel-only thing.
----- Original Message -----
From: “sankar”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 9:27 PM
Subject: [ntdev] RE: Paged and non paged memory
> Guys,
> Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
> SPECE??(high 2GB of virtual address) or does user virtual address
space also
> has non paged pool???
>
> ----- Original Message -----
> From: “McCrory, Duane”
> To: “NT Developers Interest List”
> Sent: Friday, March 14, 2003 7:35 AM
> Subject: [ntdev] RE: Paged and non paged memory
>
>
> Physical memory exists.
>
> Virtual memory isn’t really memory, but rather a mapping of
processor
> virtual addresses to page table entries.
>
> Page tables are a mechanism used by the processor and os to manage
the
> mapping of virtual memory address ranges to either physical memory
or disk
> (i.e. the swap device). Those virtual addresses that do not map to
physical
> memory are either invalid (i.e. no mapping) or swapped out (i.e. on
disk).
>
> Paged memory is a portion of physical memory that is used to
dynamically map
> virtual memory address ranges. Thus, paged memory may represent
different
> virtual memory address ranges for the same or different process over
time.
> The mapping of virtual addreses to paged memory and/or disk blocks
is
> controlled by the memory manager algorithms in the os.
>
> Non-paged memory is a portion of physical memory that is reserved by
the OS
> to not being under a paging policy. That is, the contents of these
physical
> memory blocks will not be subject to swapping to and from disk by
the memory
> manager.
>
> Pinned or locked memory usually refers to Paged memory that is
temporarily
> excluded from being swapped. Typically memory is locked down when
the
> contents are undergoing some IO operation (disk or network), and
thus the
> memory is locked so that the contents of the physical memory isn’t
modified
> by the memory manager while the contents are being accessed by the
IO h/w.
>
> Usually the os has partitioned its virtual address space into the
following
> ranges:
> 1) Pageable memory
> 2) Non-pageable memory
> 3) Memory mapped device memory (i.e. PCI device memory)
>
> Duane.
> -----Original Message-----
> From: nunch [mailto:xxxxx@free.fr]
> Sent: Friday, March 14, 2003 3:14 AM
> To: NT Developers Interest List
> Subject: [ntdev] Paged and non paged memory
>
>
> Hello,
>
> I’m new to driver development and I wonder what is the difference
between
> paged and non paged memory and what is the need to use physical
memory
> rather than virtual memory.
>
> Thanks for your answers!
>
> —
> You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
Thanks all for the replies…
So in kernel mode if we want to have non paged memory we will allocate it
from non paged pool(ExAllocatePool)…
And in user mode if I want to have some set of pages as non paged then I
guess we need to lock it
using virtuallock() API???’
Pls clarify
----- Original Message -----
From: “Maxim S. Shatskih”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 2:19 PM
Subject: [ntdev] RE: Paged and non paged memory
> No, nonpaged pool is kernel-only thing.
>
> ----- Original Message -----
> From: “sankar”
> To: “NT Developers Interest List”
> Sent: Friday, March 14, 2003 9:27 PM
> Subject: [ntdev] RE: Paged and non paged memory
>
>
> > Guys,
> > Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
> > SPECE??(high 2GB of virtual address) or does user virtual address
> space also
> > has non paged pool???
> >
> > ----- Original Message -----
> > From: “McCrory, Duane”
> > To: “NT Developers Interest List”
> > Sent: Friday, March 14, 2003 7:35 AM
> > Subject: [ntdev] RE: Paged and non paged memory
> >
> >
> > Physical memory exists.
> >
> > Virtual memory isn’t really memory, but rather a mapping of
> processor
> > virtual addresses to page table entries.
> >
> > Page tables are a mechanism used by the processor and os to manage
> the
> > mapping of virtual memory address ranges to either physical memory
> or disk
> > (i.e. the swap device). Those virtual addresses that do not map to
> physical
> > memory are either invalid (i.e. no mapping) or swapped out (i.e. on
> disk).
> >
> > Paged memory is a portion of physical memory that is used to
> dynamically map
> > virtual memory address ranges. Thus, paged memory may represent
> different
> > virtual memory address ranges for the same or different process over
> time.
> > The mapping of virtual addreses to paged memory and/or disk blocks
> is
> > controlled by the memory manager algorithms in the os.
> >
> > Non-paged memory is a portion of physical memory that is reserved by
> the OS
> > to not being under a paging policy. That is, the contents of these
> physical
> > memory blocks will not be subject to swapping to and from disk by
> the memory
> > manager.
> >
> > Pinned or locked memory usually refers to Paged memory that is
> temporarily
> > excluded from being swapped. Typically memory is locked down when
> the
> > contents are undergoing some IO operation (disk or network), and
> thus the
> > memory is locked so that the contents of the physical memory isn’t
> modified
> > by the memory manager while the contents are being accessed by the
> IO h/w.
> >
> > Usually the os has partitioned its virtual address space into the
> following
> > ranges:
> > 1) Pageable memory
> > 2) Non-pageable memory
> > 3) Memory mapped device memory (i.e. PCI device memory)
> >
> > Duane.
> > -----Original Message-----
> > From: nunch [mailto:xxxxx@free.fr]
> > Sent: Friday, March 14, 2003 3:14 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Paged and non paged memory
> >
> >
> > Hello,
> >
> > I’m new to driver development and I wonder what is the difference
> between
> > paged and non paged memory and what is the need to use physical
> memory
> > rather than virtual memory.
> >
> > Thanks for your answers!
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@hotmail.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
VirtualLock locks the pages into the working set, but does not
guarantee they will not be paged out.
Don Burn
Windows 2k/XP/2k3 Filesystem and Driver Consulting
----- Original Message -----
From: “sankar”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 5:29 PM
Subject: [ntdev] RE: Paged and non paged memory
> Thanks all for the replies…
> So in kernel mode if we want to have non paged memory we will allocate it
> from non paged pool(ExAllocatePool)…
> And in user mode if I want to have some set of pages as non paged then I
> guess we need to lock it
> using virtuallock() API???'
> Pls clarify
Yes, in kernel mode you would get non-paged memory from the non-paged
pool.
User mode applications don’t really have control over whether their
memory is paged out or not (VirtualLock is the exception, but it has
restrictions). Since they can’t run at raised IRQL they don’t really
need it since paging is always available. Drivers, on the other hand,
have several uses for locking down memory (accessing it from raised
IRQL, using it in a DMA transfer, that’s about it) and can lock down
memory provided by their user-mode clients as well as memory in the
kernel.
So your app can allocate a buffer but it will be paged. It can provide
that buffer to a kernel-mode driver through read/write/device-control
and the driver can lock the memory down if it needs to. It MUST unlock
the memory before the application terminates or the system will
bugcheck. The driver would either unlock the memory when the associated
request completes, or when it gets a cancel for the requst or a
cleanup/close on the handle the request came from.
-p
-----Original Message-----
From: sankar [mailto:xxxxx@hotmail.com]
Sent: Friday, March 14, 2003 2:29 PM
To: NT Developers Interest List
Thanks all for the replies…
So in kernel mode if we want to have non paged memory we will allocate
it from non paged pool(ExAllocatePool)…
And in user mode if I want to have some set of pages as non paged then I
guess we need to lock it using virtuallock() API???’
Pls clarify
----- Original Message -----
From: “Maxim S. Shatskih”
To: “NT Developers Interest List”
Sent: Friday, March 14, 2003 2:19 PM
Subject: [ntdev] RE: Paged and non paged memory
> No, nonpaged pool is kernel-only thing.
>
> ----- Original Message -----
> From: “sankar”
> To: “NT Developers Interest List”
> Sent: Friday, March 14, 2003 9:27 PM
> Subject: [ntdev] RE: Paged and non paged memory
>
>
> > Guys,
> > Does the nonpaged pool always reside on the KERNEL VIRTUAL ADDRESS
> > SPECE??(high 2GB of virtual address) or does user virtual address
> space also
> > has non paged pool???
> >
> > ----- Original Message -----
> > From: “McCrory, Duane”
> > To: “NT Developers Interest List”
> > Sent: Friday, March 14, 2003 7:35 AM
> > Subject: [ntdev] RE: Paged and non paged memory
> >
> >
> > Physical memory exists.
> >
> > Virtual memory isn’t really memory, but rather a mapping of
> processor
> > virtual addresses to page table entries.
> >
> > Page tables are a mechanism used by the processor and os to manage
> the
> > mapping of virtual memory address ranges to either physical memory
> or disk
> > (i.e. the swap device). Those virtual addresses that do not map to
> physical
> > memory are either invalid (i.e. no mapping) or swapped out (i.e. on
> disk).
> >
> > Paged memory is a portion of physical memory that is used to
> dynamically map
> > virtual memory address ranges. Thus, paged memory may represent
> different
> > virtual memory address ranges for the same or different process over
> time.
> > The mapping of virtual addreses to paged memory and/or disk blocks
> is
> > controlled by the memory manager algorithms in the os.
> >
> > Non-paged memory is a portion of physical memory that is reserved by
> the OS
> > to not being under a paging policy. That is, the contents of these
> physical
> > memory blocks will not be subject to swapping to and from disk by
> the memory
> > manager.
> >
> > Pinned or locked memory usually refers to Paged memory that is
> temporarily
> > excluded from being swapped. Typically memory is locked down when
> the
> > contents are undergoing some IO operation (disk or network), and
> thus the
> > memory is locked so that the contents of the physical memory isn’t
> modified
> > by the memory manager while the contents are being accessed by the
> IO h/w.
> >
> > Usually the os has partitioned its virtual address space into the
> following
> > ranges:
> > 1) Pageable memory
> > 2) Non-pageable memory
> > 3) Memory mapped device memory (i.e. PCI device memory)
> >
> > Duane.
> > -----Original Message-----
> > From: nunch [mailto:xxxxx@free.fr]
> > Sent: Friday, March 14, 2003 3:14 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Paged and non paged memory
> >
> >
> > Hello,
> >
> > I’m new to driver development and I wonder what is the difference
> between
> > paged and non paged memory and what is the need to use physical
> memory
> > rather than virtual memory.
> >
> > Thanks for your answers!
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@infiniconsys.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@hotmail.com To
> > unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
> > unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
RE
> And in user mode if I want to have some set of pages as non paged
then I
guess we need to lock it
using virtuallock() API???’
Yes, until the lock quota will be hit.
Max
>User mode applications don’t really have control over whether their
memory is paged out or not (VirtualLock is the exception, but it has
restrictions). Since they can’t run at raised IRQL they don’t really
need it since paging is always available. Drivers, on the other
hand,
Apps which maintain their own disk cache are the example of the apps
which will benefit a lot from VirtualLock on heavy load. They do file
IO in noncached mode to their cache, and they do not want the cache to
be paged out.
MSSQLServer is such. Setting the “set process working size”
parameter - which forces MSSQL to call VirtualLock - increases its
performance a lot.
Max
What about the AWE (Address Windowing Extensions) that is available
starting in Windows 2000? As I understand it, that API allows a user mode
program to allocate RAM that will not be swapped to / from the disk …
provided the administrator has given you the “Lock Pages in Memory”
privilege, of course.
Judy
Yes, in kernel mode you would get non-paged memory from the non-paged
pool.User mode applications don’t really have control over whether their
memory is paged out or not (VirtualLock is the exception, but it has
restrictions). Since they can’t run at raised IRQL they don’t really
need it since paging is always available. Drivers, on the other hand,
have several uses for locking down memory (accessing it from raised
IRQL, using it in a DMA transfer, that’s about it) and can lock down
memory provided by their user-mode clients as well as memory in the
kernel.So your app can allocate a buffer but it will be paged. It can provide
that buffer to a kernel-mode driver through read/write/device-control
and the driver can lock the memory down if it needs to. It MUST unlock
the memory before the application terminates or the system will
bugcheck. The driver would either unlock the memory when the associated
request completes, or when it gets a cancel for the requst or a
cleanup/close on the handle the request came from.-p