简体   繁体   English

磁盘数据的内存缓存

[英]Memory Caching of Data from Disk

I've always known that main memory caches data read from files on disk, but I have trouble reconciling this with the typical memory usage of a program, as shown in this diagram: 我一直都知道主内存缓存从磁盘上的文件中读取的数据,但我无法将其与程序的典型内存使用情况进行协调,如下图所示: 在此输入图像描述

If I use fread or fgetl on a very large file 2010Stats.txt , on which segment of the above diagram does memory cache data from disk? 如果我在一个非常大的文件2010Stats.txt上使用freadfgetl ,上面图表的哪个部分会从磁盘缓存数据?

That's the address-space of your process. 这是您的流程的地址空间。 Each process has its own virtual memory address-space. 每个进程都有自己的虚拟内存地址空间。 Unless you mmap a file, its data only appears in your process's memory when copied there by a read system call or equivalent. 除非您对文件进行mmap ,否则只有通过read系统调用或等效文件复制时,其数据才会显示在进程的内存中。 (C stdio / iostream functions will be implemented on top of system calls like that.) (C stdio / iostream函数将在系统调用之上实现。)

The disk-cache is managed by the OS kernel, which has to keep track of how the physical pages of memory are used, as well the virtual address mappings of every process. 磁盘高速缓存由OS内核管理,它必须跟踪内存的物理页面的使用方式,以及每个进程的虚拟地址映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM