当前位置: 代码迷 >> 驱动开发 >> 关于虚拟磁盘的有关问题
  详细解决方案

关于虚拟磁盘的有关问题

热度:23   发布时间:2016-04-28 10:29:08.0
关于虚拟磁盘的问题
请教个关于虚拟磁盘的问题,如果要划分1G或更大的内存出来给这个虚拟磁盘使用,在内核里面如何做到呢?微软自带的那个Ramdisk程序是用ExAllocatePoolWithTag来分配非分页内存的,这个函数分配的内存是有限制的,不能分配大的内存,如何分配到我当前机器的所有的剩余内存?
谢谢先。

------解决方案--------------------
弄个链表,即使是每次只分配1M,1024个不就1G了么。。。有其实位置有偏移,应该能实现1G的虚拟磁盘吧
------解决方案--------------------
PagedPoolSize and NonPagedPoolSize Values in Windows NT 

--------------------------------------------
The information in this article applies to: 
Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0 
Microsoft Windows NT Server versions 3.5, 3.51, 4.0 

--------------------------------------------

SUMMARY
Windows NT calculates NonPagedPoolSize and PagedPoolSize based on the amount of physical memory present in the computer at boot time. This article describes the algorithms used to calculate these values on an x86- based computer. 
NOTE: The Windows NT 3.5 Resource kit incorrectly describes PagedPoolSize calculations. 

MORE INFORMATION
NonPagedPoolSize and PagedPoolSize are calculated using complex algorithms based on physical memory size. However, you can use the following formulas to approximate these values for an X86-based computer. 

Definitions
MinimumNonPagedPoolSize = 256K 
MinAdditionNonPagedPoolPerMb = 32K 
DefaultMaximumNonPagedPool = 1 MB 
MaxAdditionNonPagedPoolPerMb = 400K 
PTE_PER_PAGE = 1024 
PAGE_SIZE=4096 

NonPagedPoolSize Calculation
NonPagedPoolSize = MinimumNonPagedPoolSize + ((Physical MB - 4) * MinAdditionNonPagedPoolPerMB) 
EXAMPLE - On a 32 MB x86-based computer: 

MinimumNonPagedPoolSize = 256K 
NonPagedPoolSize = 256K + ((32 - 4) * 32K) = 1.2 MB 

MaximumNonPagedPoolSize = DefaultMaximumNonPagedPool + ((Physical MB - 4) * MaxAdditionNonPagedPoolPerMB) 

If MaximumNonPagedPoolSize < (NonPagedPoolSize + PAGE_SIZE * 16), 
then MaximumNonPagedPoolSize = (NonPagedPoolSize + PAGE_SIZE * 16) 

IF MaximumNonPagedPoolSize >= 128 MB MaximumNonPagedPoolSize = 128 MB 

EXAMPLE - On a 32 MB x86-based computer: 

MaximumNonPagedPoolSize = 1 MB + ((32 - 4) * 400K) = 12.5 MB 


PagedPoolSize Calculation
Size = (2 * MaximumNonPagedPoolSize) / PAGESIZE Size = (Size + (PTE_PER_PAGE - 1)) / PTE_PER_PAGE PagedPoolSize = Size * PAGESIZE * PTE_PER_PAGE IF PagedPoolSize >= 192 MB PagePoolSize = 192 MB EXAMPLE - On a 32 MB x86-based computer: 
Size = (2 * 12.5M) / 4096 = 6400 
  相关解决方案