【翻译WINDOWS NT FILE SYSTEM INTERNAL】NT缓存管理器一(5)

本文深入探讨了NT操作系统中缓存管理器的工作原理,包括如何利用系统内存缓存文件数据,以及缓存管理器如何与其他进程共享内存资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在读写操作时缓存数据

NT操作系统中,在操作文件时候,用户进程被允许描述文件数据是否被缓存到内存。仅仅那些打开文件时没有IRP_NOCACHE标记(表示文件数据可以被缓存)才有数据被缓存到系统内存。为了理解上一章描述的NT缓存管理器提供的缓存功能 ,像考虑一个应用程序一样考虑缓存管理器,执行在系统上,他们被其他执行在相同系统上的应用程序打开的时候,很像打开一个文件。

为了缓存数据,缓存管理器不得不利用系统内存。像第五章(NT虚拟内存管理器)说明的一样,每个执行在NT环境上的进程都有4GB虚拟内存空间可用。低一半地址空间是进程描述,但高2GB用来保存操作系统,并且被共享给每个执行在系统中的进程。这个虚拟地址模型仅用于系统进程,这是一个创建于系统初始化阶段的特别进程。在系统初始化时,缓存管理器在高2GB系统进程虚拟地址空间中保留一个虚拟地址空间。因为被预留给缓存管理器专门使用的虚拟地址范围在高2GB虚拟地址空间中,每个执行在系统中的进程都可以访问NT缓存管理器预留的虚拟地址范围。图6-2显示了NT缓存管理器预留的虚拟地址空间范围位置。

尽管NT缓存管理器预留了自己专门使用的一个确认的虚拟地址范围,但是物理页内存不是必须分配给这个虚拟地址范围。被分配给缓存管理器的物理页内存的数量是确定的,NT虚拟内存管理器会不断的调整这个值。在其他用户进程或者系统组件所需要的物理内存减少时,虚拟内存管理器会给缓存管理器增加大量的物理内存。另一方面,当系统在有限的可用物理内存条件下被缓慢加载时,内存管理器会减少分配给缓存管理器(用来缓存文件数据)的物理内存数。

值得注意的是,NT虚拟内存管理器的唯一的权利是做一些关于物理内存分配的决定,这很重要。

缓存管理器使用文件映射来缓存文件数据。一个文件系统驱动通过调用缓存管理器来把缓存初始到一个文件流上。在接到一个请求时,缓存管理器调用虚拟内存管理器去创建一个段对象来表示一个文件映射,这是要对所有文件流做的事。然后,当一个进程企图访问属于一个流的数据的时候,缓存管理器动态的把文件流的视图映射为(系统虚拟内存空间中,他自己保留的)虚拟地址空间的一部分。值得注意的是,自动缓存管理器保留的虚拟地址范围被确定以后,缓存管理器可能不得不取消一个或多个之前被映射的视图,来摆正有能力创建新的视图。

为了更好地理解缓存管理器在I/O请求服务中扮演的角色,让我们来考察一下在用户发起的(user-initiated)读写操作时的典型步骤的顺序。



npm ERR! code 1 npm ERR! path D:\work\opscloud4\opscloud4-web-master\node_modules\deasync npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./build.js npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@18.19.0 | win32 | x64 npm ERR! gyp info find Python using Python version 3.12.3 found at "C:\Users\27145\AppData\Local\Programs\Python\Python312\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:113:11) npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:69:17) npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5) npm ERR! gyp ERR! stack at async createBuildDir (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:26) npm ERR! gyp ERR! stack at async run (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18) npm ERR! gyp ERR! System Windows_NT 10.0.26100 npm ERR! gyp ERR! command "D:\\ProgramFile\\developTool\\nvm_nodejs\\nodejs\\node.exe" "D:\\ProgramFile\\developTool\\nvm\\nvm\\v18.19.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd D:\work\opscloud4\opscloud4-web-master\node_modules\deasync npm ERR! gyp ERR! node -v v18.19.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok npm ERR! Build failed
最新发布
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值