如何计算松弛空间?
大小为 12,500 字节的文件将存储在扇区大小为 512 字节的硬盘驱动器上,簇由 8 个扇区组成。文件保存后还有多少剩余空间?
A file of size 12,500 bytes is to be stored on a hard disk drive where the sector size is 512 bytes, and a cluster consists of 8 sectors. How much slack space is there once the file has been saved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几点需要了解:
示例 1
给定:
在这种情况下,当分配磁盘空间来存储文件时,操作系统可以读取的最小量/write 必须是 8 个扇区或 4096 字节。
要查找松弛空间:
首先查找簇大小(以字节为单位)。簇 == 8 个扇区。
∴配额为4096。
然后查找文件大小是否大于或小于该分配大小。
2560字节< 4096.
∴只需要一个簇来保存此文件
从簇大小中减去文件大小,您就有了空闲空间。
4096 - 2560 == 1536 字节(或 3 个扇区)的闲置空间。
示例 2
给定:
在这种情况下,当磁盘空间为分配用于存储文件的操作系统可以读/写的最小数量必须是 16 个扇区或 8192 字节。
让我们完成相同的过程:
首先找到集群大小(以字节为单位)。簇 == 16 个扇区。
∴配额为8192。
然后查找文件大小是否大于或小于该分配大小。
61440字节> 8192.
∴需要几个簇来保存此文件。
由于此文件较大,请将其除以簇大小(以字节为单位)。
61440 / 8192 == 保存此文件需要 7.5 个簇。
这不是一个很好的舍入数字,因此我们必须向上舍入。回想一下,操作系统不能写入少于整个集群的数据,如果我们分配的整个集群少于必要的数量,我们将不会保存文件。
∴我们需要8个集群。
查找您的分配大小(以字节为单位)。
8 个簇 * 8192 == 65536。
从集群分配中减去文件大小,就得到了闲置空间。
65536 - 61440 == 4096 字节(或 4 个扇区)的闲置空间。
尝试一下。
A few things to know:
Example 1
Given:
In this scenario, when disk space is allocated to store the file, the smallest amount that the OS can read/write MUST be 8 sectors or 4096 bytes.
To find slack space:
first find your cluster size in bytes. Cluster == 8 sectors.
∴ allotment is 4096.
then find if the file size is larger or smaller than that allotment size.
2560 bytes < 4096.
∴ only one cluster is needed to save this file
subtract the file size from the cluster size and you have slack space.
4096 - 2560 == 1536 bytes (or 3 sectors) of slack space.
Example 2
Given:
In this scenario, when disk space is allocated to store the file, the smallest amount that the OS can read/write MUST be 16 sectors or 8192 bytes.
Let's work through the same process:
first find your cluster size in bytes. Cluster == 16 sectors.
∴ allotment is 8192.
then find if the file size is larger or smaller than that allotment size.
61440 bytes > 8192.
∴ several clusters are needed to save this file.
since this file is larger, divide it by the cluster size in bytes.
61440 / 8192 == 7.5 clusters required to save this file.
This isn't a nice round number, so we will have to round up. Recall that the OS cannot write LESS than a whole cluster and if we allot less whole clusters than necessary, we won't save the file.
∴ we require 8 clusters.
find the size in bytes of your allotment size.
8 clusters * 8192 == 65536.
subtract the file size from the cluster allotment and you have slack space.
65536 - 61440 == 4096 bytes (or 4 sectors) of slack space.
Try it.