操作系统文件分配策略

分配方法 (Allocation Method)

The allocation method defines how the files are stored in the disk blocks. The direct access nature of the disks gives us the flexibility to implement the files. In many cases, different files or many files are stored on the same disk. The main problem that occurs in the operating system is that how we allocate the spaces to these files so that the utilization of disk is efficient and the quick access to the file is possible. There are mainly three methods of file allocation in the disk. Each method has its advantages and disadvantages. Mainly a system uses one method for all files within the system.

分配方法定义文件如何存储在磁盘块中。 磁盘的直接访问特性使我们可以灵活地实现文件。 在许多情况下,不同的文件或许多文件存储在同一磁盘上。 操作系统中出现的主要问题是我们如何为这些文件分配空间,以便磁盘利用效率高,并且可以快速访问文件。 磁盘中主要有三种文件分配方法。 每种方法都有其优点和缺点。 主要是系统对系统中的所有文件使用一种方法。

  • Contiguous allocation

    连续分配

  • Linked allocation

    链接分配

  • Indexed allocation

    索引分配

The main idea behind contiguous allocation methods is to provide

连续分配方法背后的主要思想是提供

  • Efficient disk space utilization

    高效的磁盘空间利用

  • Fast access to the file blocks

    快速访问文件块

连续分配 (Contiguous allocation)

In this scheme, a file is made from the contiguous set of blocks on the disk. Linear ordering on the disk is defined by the disk addresses. In this scheme only one job is accessing the disk block b after that it accesses the block b+1 and there are no head movements. When the movement of the head is needed the head moves only from one track to another track. So the disk number that is required for accessing the contiguous allocation is minimal. Contiguous allocation method provides a good performance that’s why it is used by the IBM VM/CMS operating system. For example, if a file requires n blocks and is given a block b as the starting location, then the blocks assigned to the file will be: b, b+1, b+2,..., b+n-1. This means that given the starting block address and the length of the file (in terms of blocks required), we can determine the blocks occupied by the file. For a contiguous allocation the directory entry the address of the starting block and Length of the allocated portion.

在这种方案中,文件是由磁盘上连续的块集组成的。 磁盘上的线性顺序由磁盘地址定义。 在此方案中,只有一个作业正在访问磁盘块b,之后它才访问块b + 1,并且没有磁头移动。 当需要头部移动时,头部仅从一个轨道移动到另一轨道。 因此,访问连续分配所需的磁盘数量最少。 连续分配方法提供了良好的性能,这就是IBM VM / CMS操作系统使用它的原因。 例如,如果一个文件需要n个块,并以b作为起始位置,则分配给该文件的块将为: b,b + 1,b + 2,...,b + n-1 。 这意味着给定起始块地址和文件长度(以所需的块数为单位),我们可以确定文件所占用的块。 对于连续分配,目录条目的起始块的地址和分配部分的长度。

The file 'A' in the following figure starts from block 19 with length = 6 blocks. Therefore, it occupies 19, 20, 21, 22, 23, 24 blocks.

下图中的文件“ A”从块19开始,其长度= 6个块 。 因此,它占用19、20、21、22、23、24个块。

  • Each file in the disk occupies a contiguous address space on the disk.

    磁盘中的每个文件都占据磁盘上连续的地址空间。

  • In this scheme, the address is assigned in the linear fashion.

    在此方案中,以线性方式分配地址。

  • The is very easy to implement the contiguous allocation method.

    实现连续分配方法非常容易。

  • In the contiguous allocation technique, external fragmentation is a major issue.

    在连续分配技术中,外部碎片化是一个主要问题。

Advantages:

优点:

  1. In the contiguous allocation, sequential and direct access both are supported.

    在连续分配中,同时支持顺序访问和直接访问。

  2. For the direct access, the starting address of the kth block is given and further blocks are obtained by b+K,

    对于直接访问,给出第k个块的起始地址,并通过b + K获得其他块,

  3. This is very fast and the number of seeks is minimal in the contiguous allocation method.

    在连续分配方法中,这非常快并且搜寻次数最少。

Disadvantages:

缺点:

  1. Contiguous allocation method suffers internal as well as external fragmentation.

    连续分配方法遭受内部和外部碎片。

  2. In terms of memory utilization, this method is inefficient.

    在内存利用率方面,此方法效率低下。

  3. It is difficult to increase the file size because it depends on the availability of contiguous memory.

    很难增加文件的大小,因为它取决于连续内存的可用性。

Example:

例:

File Start Length
Count 0 2
Tr 14 3
Mail 19 6
List 28 4
文件 开始 长度
计数 0 2
Tr 14 3
邮件 19 6
清单 28 4

链接分配 (Linked allocation)

The problems of contiguous allocation are solved in the linked allocation method. In this scheme, disk blocks are arranged in the linked list form which is not contiguous. The disk block is scattered in the disk. In this scheme, the directory entry contains the pointer of the first block and pointer of the ending block. These pointers are not for the users. For example, a file of six blocks starts at block 10 and end at the block. Each pointer contains the address of the next block. When we create a new file we simply create a new entry with the linked allocation. Each directory contains the pointer to the first disk block of the file. when the pointer is nil then it defines the empty file.

链接分配方法解决了连续分配的问题。 在这种方案中,磁盘块以不连续的链表形式排列。 磁盘块分散在磁盘中。 在此方案中,目录条目包含第一个块的指针和结束块的指针。 这些指针不适用于用户。 例如,六个块的文件从块10开始,到块结束。 每个指针都包含下一个块的地址。 当我们创建一个新文件时,我们只需创建一个带有链接分配的新条目。 每个目录都包含指向文件第一个磁盘块的指针。 当指针为nil时,它将定义空文件。

Advantages:

优点:

  1. In terms of the file size, this scheme is very flexible.

    就文件大小而言,此方案非常灵活。

  2. We can easily increase or decrease the file size and system does not worry about the contiguous chunks of memory.

    我们可以轻松地增加或减少文件大小,并且系统不必担心连续的内存块。

  3. This method free from external fragmentation this makes it better in terms of memory utilization.

    此方法没有外部碎片,因此在内存利用率方面更好。

Disadvantages:

缺点:

  1. In this scheme, there is large no of seeks because the file blocks are randomly distributed on disk.

    在这种方案中,由于文件块是随机分布在磁盘上的,因此不需要大量查找。

  2. Linked allocation is comparatively slower than contiguous allocation.

    链接分配比连续分配要慢。

  3. Random or direct access is not supported by this scheme we cannot access the blocks directly.

    此方案不支持随机或直接访问,我们无法直接访问块。

  4. The pointer is extra overhead on the system due to the linked list.

    由于链接列表,指针在系统上会产生额外的开销。

索引分配 (Indexed Allocation)

In this scheme, a special block known as the index block contains the pointer to all the blocks occupied by a file. each file contains its index which is in the form of an array of disk block addresses. The ith entry of index block point to the ith block of the file. The address of the index block is maintained by the directory. When we create a file all pointer is set to nil. A block is obtained from the free space manager when the first ith block is written. When the index block is very small it is difficult to hold all the pointers for the large file. to deal with this issue a mechanism is available. Mechanism includes the following:

在此方案中,称为索引块的特殊块包含指向文件所占据的所有块的指针。 每个文件都包含其索引,该索引采用磁盘块地址数组的形式。 索引块的第i个条目指向文件的第i个块。 索引块的地址由目录维护。 创建文件时,所有指针都设置为nil。 当第一个第i个块被写入时,将从可用空间管理器中获得一个块。 当索引块很小时,很难保存大文件的所有指针。 解决此问题的机制是可用的。 机制包括以下内容:

  • Linked scheme

    链接方案

  • Multilevel scheme

    多级方案

  • Combined scheme

    组合方案

Advantages:

优点:

  1. This scheme supports random access of the file.

    该方案支持文件的随机访问。

  2. This scheme provides fast access to the file blocks.

    该方案提供对文件块的快速访问。

  3. This scheme is free from the problem of external fragmentation.

    该方案没有外部碎片的问题。

Disadvantages:

缺点:

  1. The pointer head is relatively greater than the linked allocation of the file.

    指针头相对大于文件的链接分配。

  2. Indexed allocation suffers from the wasted space.

    索引分配遭受空间浪费。

  3. For the large size file, it is very difficult for single index block to hold all the pointers.

    对于大文件,单个索引块很难容纳所有指针。

  4. For very small files say files that expend only 2-3 blocks the indexed allocation would keep on the entire block for the pointers which is insufficient in terms of memory utilization.

    对于很小的文件,例如仅消耗2-3个块的文件,索引分配将保留整个块的指针,这在内存利用率方面是不够的。

翻译自: https://www.includehelp.com/operating-systems/file-allocation-method.aspx

操作系统文件分配策略

操作系统文件分配策略_操作系统中的文件分配方法相关推荐

  1. 操作系统饥饿现象_操作系统心得体会

    一.操作系统 1.基本概念 操作系统简称OS,是配置在计算机硬件上的第一层软件,它能够有效的组织和管理计算机系统中的硬件和软件资源,合理的组织计算机工作流程,控制程序的执行,并向用户提供各种服务功能. ...

  2. 接口中默认方法和静态方法_接口中的默认方法和静态方法

    接口中默认方法和静态方法 在我们最初的Java 8支持公告中,我们特别提到了流的缺乏,但完全错过了默认/静态本机接口不起作用的事实. 现在,由于有一个警惕的社区成员指出了这一问题,因此此问题已得到解决 ...

  3. 操作系统饥饿现象_操作系统中的饿死现象怎样理解?

    什么是进程的饥饿和饿死? 在一个动态系统中,资源请求与释放是经常性发生的进程行为.对于每类系统资源,操作系统需要确定一个分配策略,当多个进程同时申请某类资源时,由分配策略确定资源分配给进程的次序. 资 ...

  4. 操作系统多线程实现_操作系统中的线程实现

    操作系统多线程实现 Each process has an address space. There is one thread of control in every traditional OS. ...

  5. 操作系统 系统开销比率_操作系统中的最高响应比率下一个(HRRN)调度

    操作系统 系统开销比率 操作系统中的HRRN调度是什么? (What is HRRN Scheduling in Operating System?) HRRN is the abbreviation ...

  6. 操作系统饥饿现象_操作系统常见面试题

    1.进程的常见状态?以及各种状态之间的转换条件? 就绪:进程已处于准备好运行的状态,即进程已分配到除CPU外的所有必要资源后,只要再获得CPU,便可立即执行. 执行:进程已经获得CPU,程序正在执行状 ...

  7. 操作系统内存管理_操作系统6内存管理基础

    引言 花了一段时间才把之前的笔记整理了一部分,平时太忙也没啥时间.今天开始整理内存管理部分的,内存管理部分大致分为三部分笔记,第一部分就是本篇内存管理基础,第二部分是虚拟内存,第三部分高速缓存. 一个 ...

  8. 操作系统饥饿现象_操作系统复习

    的最小值是 ( ) A . 2 B.3 C.4 D.5 4.n 个进程共享某一临界资源,则互斥信号量的取值范围为( ) . A. 0~1     B. – 1~0            C. 1~-( ...

  9. python操作系统课程设计_操作系统课程设计.pdf

    计算机科学与通信工程学院 操作系统课程设计报告 题目:linux系统下实现PV 操作 班级: 软件工程1401 姓名: 吴帅帅 学号: 3140608020 指导老师: 牛德姣 2016 年12 月2 ...

最新文章

  1. Java系列: JAVA字符串格式化-String.format()的使用(zz)
  2. 第14、15週PTA題目的處理
  3. 1. CMake 系列 - 从零构建动态库和静态库
  4. android11beta支持什么手机,Android 11 Beta1发布,新增多种功能,网友:Android基于 Flyme...
  5. leetcode 850. Rectangle Area II | 850. 矩形面积 II(递归分割未重叠矩形)
  6. 与指定数字相同的数的个数(信息学奥赛一本通-T1068)
  7. 用css3制作一个Music Player Menu
  8. 如何用报表解决销售工作衡量问题
  9. c# java gt;gt;gt;,C#的相当于Java的&LT ;?扩展底座>在仿制药
  10. 【转】opengl的一些小问题
  11. c语言换行后多空格,关于文件操作,碰到空格就换行
  12. 安卓Tv端App开发与手机端的开发的区别
  13. 计算机无法识别sd存储卡,Win7系统电脑插入SD卡提示“无法读取SD卡”的解决方法...
  14. dubbo源码导入eclipse
  15. IJCAI2021会议论文列表(可下载)
  16. conda创建的虚拟环境可以直接复制走放到另外一个电脑上用吗
  17. Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local
  18. 基于51单片机的温度甲烷监测报警串口上报proteus仿真原理图PCB
  19. 中兴以太网板see服务器地址,中兴传输以太网板数据配置.ppt
  20. 【与公主对话】爱情的本质是什么

热门文章

  1. 华北水利水电大学c语言程序设计四_我校代表队在“中国高等计算机大赛——团体程序设计天梯赛” 中喜获佳绩...
  2. sql中in与php数组,格式化SQL“IN”子句的PHP数组
  3. sqli-lab————Writeup(18~20)各种头部注入
  4. php对中英文字符串进行截取,利用php怎么对中英文混合的字符串进行截取
  5. java sound 多线程同一音频文件_Java在编程语言中占据何等优势?
  6. pyqt5 下拉 多页 点击_PyQt5实战——自定义翻页控件实现
  7. 趣学java,编程趣学习app
  8. java 导出bcp文件格式_使用BCP导出导入数据
  9. data.frame类型数据如何将第一列值替换为行号
  10. iOS开发之解决系统数字键盘无文字时delete键无法监听的技巧