系统盘压缩卷小于可用空间
可用空间管理 (Free space management)
As we know that the memory space in the disk is limited. So we need to use the space of the deleted files for the allocation of the new file. one optical disk allows only one write at a time in the given sector and thus it is not physically possible to reuse it for other files. The system maintains a free space list by keep track of the free disk space. The free space list contains all the records of the free space disk block. Thee free blocks are those which are not allocated to other file or directory. When we create a file we first search for the free space in the memory and then check in the free space list for the required amount of space that we require for our file. if the free space is available then allocate this space to the new file. After that, the allocating space is deleted from the free space list. Whenever we delete a file then its free memory space is added to the free space list.
众所周知,磁盘中的存储空间是有限的。 因此,我们需要使用已删除文件的空间来分配新文件。 一个光盘一次只能在给定扇区中进行一次写操作,因此在物理上不可能将其重用于其他文件。 系统通过跟踪可用磁盘空间来维护可用空间列表。 可用空间列表包含可用磁盘块的所有记录。 空闲块是未分配给其他文件或目录的块。 创建文件时,我们首先在内存中搜索可用空间,然后在可用空间列表中检查文件所需的空间量。 如果可用空间可用,则将该空间分配给新文件。 之后,分配空间将从可用空间列表中删除。 每当我们删除文件时,它的可用内存空间就会添加到可用空间列表中。
The process of looking after and managing the free blocks of the disk is called free space management. There are some methods or techniques to implement a free space list. These are as follows:
照顾和管理磁盘的空闲块的过程称为空闲空间管理。 有一些方法或技术可以实现空闲空间列表。 这些如下:
Bitmap
位图
Linked list
链表
Grouping
分组
Counting
数数
1.位图 (1. Bitmap)
This technique is used to implement the free space management. When the free space is implemented as the bitmap or bit vector then each block of the disk is represented by a bit. When the block is free its bit is set to 1 and when the block is allocated the bit is set to 0. The main advantage of the bitmap is it is relatively simple and efficient in finding the first free block and also the consecutive free block in the disk. Many computers provide the bit manipulation instruction which is used by the users.
此技术用于实现自由空间管理。 当可用空间被实现为位图或位向量时,则磁盘的每个块都由一个位表示。 当该块空闲时,其位设置为1,当分配该块时,该位设置为0。位图的主要优点是,在找到第一个空闲块以及其中的连续空闲块时,它相对简单有效。磁盘。 许多计算机提供用户使用的位操作指令。
The calculation of the block number is done by the formula:
块号的计算由以下公式完成:
(number of bits per words) X (number of 0-value word) + Offset of first 1 bit
(每个字的位数)X(0值字的数量)+前1位的偏移量
For Example: Apple Macintosh operating system uses the bitmap method to allocate the disk space.
例如: Apple Macintosh操作系统使用位图方法分配磁盘空间。
Assume the following are free. Rest are allocated:
假设以下内容是免费的。 其余分配:
Advantages:
优点:
This technique is relatively simple.
此技术相对简单。
This technique is very efficient to find the free space on the disk.
此技术对于查找磁盘上的可用空间非常有效。
Disadvantages:
缺点:
This technique requires a special hardware support to find the first 1 in a word it is not 0.
此技术需要特殊的硬件支持,才能找到单词中不为0的第一个1。
This technique is not useful for the larger disks.
此技术对较大的磁盘没有用。
For example: Consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18, 25,26, and 27 are free and the rest of the blocks are allocated. The free-space bitmap would be: 001111001111110001100000011100000
例如:考虑一个磁盘,其中块2、3、4、5、8、9、10、11、12、13、17、18、25、26和27是空闲的,其余块已分配。 可用空间位图将是:001111001111110001100000011100000
2.链表 (2. Linked list)
This is another technique for free space management. In this linked list of all the free block is maintained. In this, there is a head pointer which points the first free block of the list which is kept in a special location on the disk. This block contains the pointer to the next block and the next block contain the pointer of another next and this process is repeated. By using this disk it is not easy to search the free list. This technique is not sufficient to traverse the list because we have to read each disk block that requires I/O time. So traversing in the free list is not a frequent action.
这是用于自由空间管理的另一种技术。 在此所有空闲块的链接列表中,将保留该块。 在此,有一个头指针,它指向列表的第一个空闲块,该块保留在磁盘上的特殊位置。 该块包含指向下一个块的指针,下一个块包含另一个下一个块的指针,并重复此过程。 通过使用该磁盘,搜索空闲列表并不容易。 这种技术不足以遍历列表,因为我们必须读取每个需要I / O时间的磁盘块。 因此,在空闲列表中遍历不是经常的操作。
Advantages:
优点:
Whenever a file is to be allocated a free block, the operating system can simply allocate the first block in free space list and move the head pointer to the next free block in the list.
每当要为文件分配空闲块时,操作系统都可以简单地在空闲空间列表中分配第一个块,并将头指针移动到列表中的下一个空闲块。
Disadvantages:
缺点:
Searching the free space list will be very time consuming; each block will have to be read from the disk, which is read very slowly as compared to the main memory.
搜索可用空间列表将非常耗时; 每个块都必须从磁盘读取,与主存储器相比,磁盘读取速度非常慢。
Not Efficient for faster access.
无法快速访问。
In our earlier example, we see that keep block 2 is the first free block which points to another block which contains the pointer of the 3 blocks and 3 blocks contain the pointer to the 4 blocks and this contains the pointer to the 5 block then 5 block contains the pointer to the next block and this process is repeated at the last .
在我们前面的示例中,我们看到keep块2是第一个空闲块,它指向另一个包含3个块的指针的块,而3个块包含指向4个块的指针,并且包含指向5个块的指针,然后是5块包含指向下一个块的指针,最后重复这个过程。
3.分组 (3. Grouping)
This is also the technique of free space management. In this, there is a modification of the free-list approach which stores the address of the n free blocks. In this the first n-1 blocks are free but the last block contains the address of the n blocks. When we use the standard linked list approach the addresses of a large number of blocks can be found very quickly. In this approach, we cannot keep a list of n free disk addresses but we keep the address of the first free block.
这也是自由空间管理的技术。 在此,对空闲列表方法进行了修改,该方法存储了n个空闲块的地址。 这样,前n-1个块是空闲的,但最后一个块包含n个块的地址。 当我们使用标准链表方法时,可以很快找到大量块的地址。 在这种方法中,我们无法保留n个可用磁盘地址的列表,但保留了第一个可用块的地址。
4.计数 (4. Counting)
Counting is another approach for free space management. Generally, some contiguous blocks are allocated but some are free simultaneously. When the free space is allocated to a process according to the contiguous allocation algorithm or clustering. So we cannot keep the list of n free block address but we can keep the address of the first free block and then the numbers of n free contiguous block which follows the first block. When there is an entry in the free space list it consists the address of the disk and a count variable. This method of free space management is similar to the method of allocating blocks. We can store these entries in the B-tree in place of the linked list. So the operations like lookup, deletion, insertion are efficient.
计数是可用空间管理的另一种方法。 通常,分配一些连续的块,但同时释放一些。 当根据连续分配算法或集群将可用空间分配给进程时。 因此,我们不能保留n个空闲块地址的列表,但可以保留第一个空闲块的地址,然后保留第一个块之后的n个连续块的数目。 当可用空间列表中有一个条目时,它由磁盘地址和一个计数变量组成。 这种可用空间管理方法类似于分配块的方法。 我们可以将这些条目存储在B树中,代替链接列表。 因此,查找,删除,插入等操作非常有效。
翻译自: https://www.includehelp.com/operating-systems/free-space-management.aspx
系统盘压缩卷小于可用空间