操作系统文件分配策略_操作系统中的文件分配方法

操作系统文件分配策略

分配方法 (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:

例:

FileStartLength
Count02
Tr143
Mail196
List284
文件 开始 长度
计数 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

操作系统文件分配策略

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541400.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

简述container与container-fluid的区别

在bootstrap中的布局容器一栏中,提供了container与container-fluid两种容器,其官方解释为: .container 类用于固定宽度并支持响应式布局的容器。 .container-fluid 类用于 100% 宽度,占据全部视口(viewport&#xff09…

centos php fpm 停止_如何关闭php-fpm进程?

因为你是编译的,可以在源码中复制php-fpm的init文件到系统中:cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm然后就可以使用以下命令启动、停止、重启和重新加载php-fpm了:service php-fpm startservice php-fpm restartservice php-fpm…

minus_Java Duration类| minus()方法与示例

minus持续时间类minus()方法 (Duration Class minus() method) Syntax: 句法: public Duration minus(Duration d);public Duration minus(long amt, TemporalUnit t_unit);minus() method is available in java.time package. minus()方法在java.time包中可用。 m…

Mongodb聚合函数

插入 测试数据 for(var j1;j<3;j){ for(var i1;i<3;i){ var person{Name:"jack"i,Age:i,Address:["henan","wuhan"],Course:[{Name:"shuxue",Score:i},{Name:"wuli",Score:i}]}db.DemoTest.Person.insert(pers…

php rename函数_php rename函数怎么用

PHP rename()函数用于重命名文件或目录&#xff0c;语法“rename(文件旧名称,新名称,句柄环境)”&#xff0c;使用用户指定的新名称更改文件或目录的旧名称&#xff0c;并且可以根据需要在目录之间移动&#xff1b;成功时返回True&#xff0c;失败时返回False。php rename()函数…

Java BigInteger类| xor()方法与示例

BigInteger类的xor()方法 (BigInteger Class xor() method) xor() method is available in java.math package. xor()方法在java.math包中可用。 xor() method is used to perform xor operation between this BigInteger and the given BigInteger and we all know when we pe…

Spring Data Redis实战之提供RedisTemplate

为什么80%的码农都做不了架构师&#xff1f;>>> 参考&#xff1a; http://www.cnblogs.com/edwinchen/p/3816938.html 本项目创建的是Maven项目 一、pom.xml引入dependencies <dependency><groupId>org.springframework.data</groupId><artif…

Java BigInteger类| and()方法与示例

BigInteger类和()方法 (BigInteger Class and() method) and() method is available in java.math package. and()方法在java.math包中可用。 and() method is used to perform and operation between this BigInteger and the given BigInteger (val) [i.e. (this BigInteger)…

php映射,PHP实现路由映射到指定控制器

自定义路由的功能&#xff0c;指定到pathinfo的url上,再次升级之前的脚本SimpleLoader.phpclass SimpleLoader{public static function run($rulesarray()){header("content-type:text/html;charsetutf-8");self::register();self::commandLine();self::router($rule…

stl vector 函数_vector :: clear()函数,以及C ++ STL中的示例

stl vector 函数C vector :: clear()函数 (C vector::clear() function) vector::clear() is a library function of "vector" header, it is used to remove/clear all elements of the vector, it makes the 0 sized vector after removing all elements. vector …

Commonjs规范及Node模块实现

前面的话 Node在实现中并非完全按照CommonJS规范实现&#xff0c;而是对模块规范进行了一定的取舍&#xff0c;同时也增加了少许自身需要的特性。本文将详细介绍NodeJS的模块实现 引入 nodejs是区别于javascript的&#xff0c;在javascript中的顶层对象是window&#xff0c;而在…

thinkphp3 php jwt,ThinkPHP5 使用 JWT 进行加密

- 使用 Composer安装此扩展- 代码示例<?php /*** [InterCommon-接口公用]* Author RainCyan* DateTime 2019-08-12T16:38:080800*/namespace app\hladmin\controller;use think\Controller;use \Firebase\JWT\JWT;class InterCommonController extends Controller {private…

数据管理与商业智能_商业智能与数据科学

数据管理与商业智能In this heavily jargonized trade, the words typically overlap one another, leading to a scarcity of understanding or a state of confusion around these ideas. whereas big data vs analytics or computing vs machine learning vs cognitive inte…

JavaWeb网上图书商城完整项目--day02-14.登录功能的login页面处理

1、现在注册成功之后&#xff0c;我们来到登录页面&#xff0c;登录页面在于 在登录页面。我们也需要向注册页面一样对登录的用户名、密码 验证码等在jsp页面中进行校验&#xff0c;校验我们单独放置一个login.js文件中进行处理&#xff0c;然后login.jsp加载该js文件 我们来看…

php多线程是什么意思,多线程是什么意思

线程是操作系统能够进行运算调度的最小单位&#xff0c;它被包含在进程之中&#xff0c;是进程中的实际运作单位&#xff0c;而多线程就是指从软件或者硬件上实现多个线程并发执行的技术&#xff0c;具有多线程能力的计算机因有硬件支持而能够在同一时间执行多于一个线程&#…

c++一个类创建多个对象_C ++ | 创建一个类的多个对象

c一个类创建多个对象In the below program, we are creating a C program to create multiple objects of a class. 在下面的程序中&#xff0c;我们正在创建一个C 程序来创建一个类的多个对象 。 /* C program to create multiple objects of a class */#include <iostrea…

Activity中与ListActivity中使用listview区别

一.Activity中与ListActivity中使用listview区别&#xff08;本身没多大区别&#xff0c;只是ListActivity在listview的显示上做了一些优化&#xff09;Activity中使用Listview步骤&#xff1a;1.xml布局中,ListView标签id可以任意取值如&#xff1a;<ListView andro…

java相关是什么,什么是java

java基础常见面试题&#xff0c;这是一篇超长的随笔&#xff01;&#xff01;&#xff01;1. Java基础部分....................................................... 4 1、一个".java"源文件中是否可以包括多个类(不是内部类)&#xff1f;有什么限制&#xff1f;.. …

如何在Scala中将Double转换为String?

Double in Scala is a data type that stores numerical values that have decimals. It can store a 64-bit floating point number. Scala中的Double是一种数据类型&#xff0c;用于存储带有小数的数值。 它可以存储一个64位浮点数。 Example: 例&#xff1a; val decimal…

basic knowledge

Position 属性&#xff1a;规定元素的定位类型。即元素脱离文档流的布局&#xff0c;在页面的任意位置显示。 ①absolute &#xff1a;绝对定位&#xff1b;脱离文档流的布局&#xff0c;遗留下来的空间由后面的元素填充。定位的起始位置为最近的父元素(postion不为static)&…