我们对应用程序级别的文件的页面/块是什么意思? [英] What do we mean with pages/blocks for files in the application level?

查看:137
本文介绍了我们对应用程序级别的文件的页面/块是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我阅读教科书中的文件时,似乎对应用程序级别的文件重复了关于操作系统的一些概念。

例如术语用于文件中的数据的逻辑表示(因此我们不在HD级组织中)。但我不明白这里的想法是什么。我们在应用程序中是否定义了块大小和页面大小,并在访问文件时使用它们。使用NIO或阻塞IO?

我们将如何正常定义这些大小?任意地我在这里困惑吗?



@RobinGreen请求后更新

我所说的一个例子是例如时隙块页面结构或例如可变长度记录的列表表示。在Silberschatz的数据库系统一书中的文件部分中的概要

解决方案

在Linux中,操作系统块大小与硬盘报告的扇区大小(以字节为单位无关)(这也是假的,因为BIOS兼容性原因!)。



在应用程序级别,您可以将数据存储在与OS级别块无关的固定大小或可变大小的块中。



所以有很多级别,彼此无关! / p>

然而,当然,以块形式读取和写入数据是个好主意。一次读取和写入1个字节的数据将涉及到内核的往返次数过多,例如。但是正确的使用大小是一个经验问题:哪个大小对您的用例最有效?



页面大小略有不同。它们由CPU体系结构(至少在x86 / x86_64系列中)定义,并影响分页/交换。应用程序不会直接遇到分页和交换,而是在较低的性能方面遇到影响。


When I read about files in textbooks it seems that some concepts I knew about OS are repeated for files on the application level.
For example the terms block and page are used for logical representation of data in files (so we are not in the HD level organization). But I can not understand what is the idea here. Do we in the application define a block size and a page size and use that when accessing files e.g. using NIO or blocking IO?
How would we define these sizes normally? Arbitrarily? Am I confused here?

UPDATE after request of @RobinGreen
An example of what I am saying is e.g. the slotted-block page structure or the list representation for variable length records described e.g. in the book of Silberschatz for Database System concepts in the section for files

解决方案

In Linux, the operating system block size is unrelated to the hard drive's reported sector size in bytes (which is also fake these days - for BIOS compatibility reasons!).

At the application level, you can store data in fixed-size or variable-size blocks, which are unrelated to OS level blocks.

So there are many levels, all unrelated to each other!

Of course it is a good idea to read and write data in chunks, nevertheless. Reading and writing data 1 byte at a time would involve too many round-trips to the kernel, for example. But the right size to use is an empirical question: which size is most efficient for your use case?

Page sizes are slightly different. They are defined by the CPU architecture (at least on the x86/x86_64 family) and affect paging/swapping. An application does not directly encounter paging and swapping, but it encounters the effects, in terms of lower performance.

这篇关于我们对应用程序级别的文件的页面/块是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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