进程之间的文件缓存 [英] File Caching between processes

查看:58
本文介绍了进程之间的文件缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在Windows和Linux下,文件缓存在进程之间起作用吗?如果进程A读取了整个文件,而新进程B想要读取文件的一部分(或全部),那么假设文件已经在内存中是否有意义?还是仅在每个进程中的每个文件对象中进行缓存?

I'm interested in knowing under windows and linux, does file caching work between processes? if process A reads the whole file, and a new process B wants to read parts of it (or all of it), would it make sense to assume the file is already in memory? or does the caching happen only per file object in each process?

推荐答案

Windows和Linux都将文件数据缓存在系统内存中,与进程分开.但是,您无法对在任何给定时间仍有多少文件(如果有)进行缓存.

Both Windows and Linux cache file data in system memory, separate from processes. You can't make any assumptions on how much of the file, if any, is still in cache at any given time, however.

在较高级别上,操作系统维护固定大小页面的高速缓存(在Linux上通常为4 KB,在Windows上通常为256 KB).每个页面包含一个文件的一部分.当您的进程进行读取时,操作系统将在高速缓存中搜索包含您请求的数据的页面.如果找不到所需的所有数据,它将从磁盘中将所需的页面读取到缓存中,可能会覆盖其他现有页面.

At a high level, the operating system maintains a cache of fixed-size pages (normally 4 KB on Linux, 256 KB on Windows). Each page contains part of a file. When your process does a read, the operating system searches the cache for pages with the data you requested. If it can't find all of the data you requested, it reads the required pages into the cache from disk, possibly overwriting other existing pages.

这篇关于进程之间的文件缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆