Why do you need your memory to be physically contiguous?
It's actually not clear to me why you need the memory to be virtually
contiguous either. Your virtual disk driver will be handling Read &
Write requests and you can easily walk through a table to find the
memory block which holds the data for any particular disk offset. This
would let you allocate memory in smaller chunks, and might even let you
keep large amounts of the disk unallocated if it hadn't ever been
written to.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of CheckAbdoul
Sent: Monday, June 05, 2006 3:03 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Locking Paged pool Memory
Thanks Scott. Looks like both ( allocating from paged pool &
non-paged pool ) of my approaches are wrong. So, what is the proper way
to create a memory disk which can hold around 150MB worth of file data ?
--
Cheers
Check Abdoul
"Scott Noone" wrote in message news:xxxxx@ntdev...
>> Thanks for the suggestion. By the way if I use
>> ExAllocatePoolWithTag(PagedPool,... ) is the allocated memory
>> contiguous ?
>
> Nope, no reason to believe that a multi-page pool buffer will be
> physically contiguous.
>
> -scott
>
> --
> Scott Noone
> Software Engineer
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
> "CheckAbdoul" wrote in message
news:xxxxx@ntdev...
>> Hi Mark,
>>
>> Thanks for the suggestion. By the way if I use
>> ExAllocatePoolWithTag(PagedPool,... ) is the allocated memory
>> contiguous ?
>>
>> I am trying to have a memory disk that can hold around 150MB
>> of files. I tried allocating from the non-paged pool but the OS is
>> allowing me to allocate only 127MB ( on a 2003 R2 system ) regardless
>> of whatever values I tried with the "NonPagedPoolSize" registry key.
>> If I understood you correctly, can you tell me if the following will
work ?
>>
>>
>> #define MEMREQUIRED 0x9600000; /* 150 MB */
>> MyDiskAlloc()
>> {
>> pMem = ExAllocatePoolWithTag(PagedPool, MEMREQUIRED, MYTAG
) ;
>> PMDL mdl = IoAllocateMdl( pMem , MEMREQUIRED, FALSE,
>> FALSE, NULL );
>> if( !mdl )
>> {
>> ntStatus = STATUS_INSUFFICIENT_RESOURCES;
>> ExFreePoolWithTag( pMem , MYTAG );
>> return ntStatus;
>> }
>>
>> try
>> {
>> MmProbeAndLockPages(mdl, KernelMode,
IoWriteAccess);
>> }
>> except(EXCEPTION_EXECUTE_HANDLER)
>> {
>> NTSTATUS status = GetExceptionCode();
>> IoFreeMdl(mdl);
>> mdl = NULL;
>> }
>>
>> }
>>
>> MyDiskFree()
>> {
>> // cleanup code
>> MmUnlockPages( mdl );
>> IoFreeMdl(mdl);
>> mdl = NULL;
>> }
>>
>>
>>
>> --
>> Cheers
>> Check Abdoul
>> ------------------
>>
>>
>>
>> "Mark J. Cariddi" wrote in message
news:xxxxx@ntdev...
>>> Sure, allocate an MDL for it and the do an MmProbeAndLockPages.
>>>
>>> Remember to do an MMUnlockpages before freeing the MDL.
>>>
>>> --Mark Cariddi
>>> OSR, Open SYstems Resources, Inc.
>>>
>>> On Mon, 5 Jun 2006 15:54:46 -0400, "CheckAbdoul"
>>> wrote:
>>>
>>>>Hi Group,
>>>>
>>>> After allocating memory using ExAllocatePoolWithTag(
>>>>PagedPool,... ), is there a way to lock it in, so that it is always
>>>>resident and never pages out ? If so, how to do it from my kernel
>>>>driver ? Note that I am interested in allocating only from PagedPool
>>>>and lock it in and I will be doing this only if there is more than
>>>>1GB of physical memory in the box.
>>>
>>
>>
>>
>
>
>
---
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
ListServer/Forum