操作系统 非连续分配
In this article, we will learn about the different types of memory management techniques and also the pros and cons of different memory management techniques.
在本文中,我们将学习不同类型的内存管理技术 ,以及不同内存管理技术的优缺点。
Memory management
内存管理
Memory is central to the operation of a computer system. It consists of a large array of words or bytes each with its own address. In uniprogramming system, main memory has two parts one for the operating system and another part is for the program currently being executed. In the multiprogramming system, the memory part of the user is further divided into accommodate processes. The task of the subdivision is cannot out by the operating system and is known as memory management.
内存对于计算机系统的运行至关重要。 它由大量的单词或字节组成,每个单词或字节都有自己的地址。 在单编程系统中,主存储器分为两部分,一部分用于操作系统,另一部分用于当前正在执行的程序。 在多程序系统中,用户的存储部分被进一步分为容纳过程。 细分的任务无法由操作系统执行,因此称为内存管理。
Memory management techniques
内存管理技术
The memory management techniques is divided into two parts...
内存管理技术分为两部分...
Uniprogramming:
单编程:
In the uniprogramming technique, the RAM is divided into two parts one part is for the resigning the operating system and other portion is for the user process. Here the fence register is used which contain the last address of the operating system parts. The operating system will compare the user data addresses with the fence register and if it is different that means the user is not entering in the OS area. Fence register is also called boundary register and is used to prevent a user from entering in the operating system area. Here the CPU utilization is very poor and hence multiprogramming is used.
在单编程技术中,RAM分为两部分,一部分用于重新命名操作系统,另一部分用于用户进程。 这里使用了篱笆寄存器,其中包含操作系统部件的最后地址。 操作系统会将用户数据地址与篱笆寄存器进行比较,如果不同,则意味着用户没有进入OS区域。 栅栏寄存器也称为边界寄存器,用于防止用户进入操作系统区域。 在这里,CPU利用率非常差,因此使用了多程序。
Multiprogramming:
多重编程:
In the multiprogramming, the multiple users can share the memory simultaneously. By multiprogramming we mean there will be more than one process in the main memory and if the running process wants to wait for an event like I/O then instead of sitting ideal CPU will make a context switch and will pick another process.
在多重编程中,多个用户可以同时共享存储器。 通过多程序,我们意味着主内存中将有多个进程,并且如果正在运行的进程要等待I / O之类的事件,则与其坐拥理想的CPU,而是进行上下文切换,然后选择另一个进程。
- Contiguous memory allocation
- Non-contiguous memory allocation
a)连续内存分配 (a) Contiguous memory allocation)
In contiguous memory allocation, all the available memory space remain together in one place. It means freely available memory partitions are not scattered here and there across the whole memory space.
在连续内存分配中 ,所有可用内存空间都在一起放在一个位置。 这意味着免费可用的内存分区不会分散在整个内存空间中。
In the contiguous memory allocation, both the operating system and the user must reside in the main memory. The main memory is divided into two portions one portion is for the operating and other is for the user program.
在连续内存分配中 ,操作系统和用户都必须驻留在主内存中。 主存储器分为两部分,一部分用于操作,另一部分用于用户程序。
In the contiguous memory allocation when any user process request for the memory a single section of the contiguous memory block is given to that process according to its need. We can achieve contiguous memory allocation by dividing memory into the fixed-sized partition.
在连续存储器分配中,当任何用户处理请求该存储器时,根据其需要将连续存储块的单个部分提供给该处理。 通过将内存划分为固定大小的分区,我们可以实现连续的内存分配。
A single process is allocated in that fixed sized single partition. But this will increase the degree of multiprogramming means more than one process in the main memory that bounds the number of fixed partition done in memory. Internal fragmentation increases because of the contiguous memory allocation.
在该固定大小的单个分区中分配一个进程。 但是,这将增加多程序化的程度,这意味着主内存中有多个进程限制了内存中固定分区的数量。 内部碎片的增加是由于连续的内存分配。
→ Fixed sized partition
→固定大小的分区
In the fixed sized partition the system divides memory into fixed size partition (may or may not be of the same size) here entire partition is allowed to a process and if there is some wastage inside the partition is allocated to a process and if there is some wastage inside the partition then it is called internal fragmentation.
在固定大小的分区中,系统将内存划分为固定大小的分区(大小可能相同,也可能不同),此处允许将整个分区分配给一个进程,如果该分区内部有一些浪费,则将其分配给进程分区中的一些浪费,然后称为内部碎片。
Advantage: Management or book keeping is easy.
优点:管理或簿记都很容易。
Disadvantage: Internal fragmentation
缺点:内部碎片化
→ Variable size partition
→可变大小的分区
In the variable size partition, the memory is treated as one unit and space allocated to a process is exactly the same as required and the leftover space can be reused again.
在可变大小分区中,内存被视为一个单元,分配给进程的空间与所需的空间完全相同,剩余的空间可再次使用。
Advantage: There is no internal fragmentation.
优点:没有内部碎片。
Disadvantage: Management is very difficult as memory is becoming purely fragmented after some time.
缺点:管理非常困难,因为一段时间后内存将变得完全碎片化。
b)非连续内存分配 (b) Non-contiguous memory allocation)
In the non-contiguous memory allocation the available free memory space are scattered here and there and all the free memory space is not at one place. So this is time-consuming. In the non-contiguous memory allocation, a process will acquire the memory space but it is not at one place it is at the different locations according to the process requirement. This technique of non-contiguous memory allocation reduces the wastage of memory which leads to internal and external fragmentation. This utilizes all the free memory space which is created by a different process.
在非连续的内存分配中 ,可用的空闲内存空间分散在各处,并且所有空闲内存空间都不在一个地方。 因此,这很耗时。 在非连续的内存分配中 ,一个进程将获取内存空间,但是根据该进程的要求,它并不位于一个位置,而是位于不同的位置。 这种非连续的内存分配技术可减少内存浪费,从而导致内部和外部碎片。 这将利用由不同进程创建的所有可用内存空间。
Non-contiguous memory allocation is of different types,
非连续内存分配类型不同,
Paging
分页
Segmentation
分割
Segmentation with paging
分页细分
i) Paging
i)分页
A non-contiguous policy with a fixed size partition is called paging. A computer can address more memory than the amount of physically installed on the system. This extra memory is actually called virtual memory. Paging technique is very important in implementing virtual memory. Secondary memory is divided into equal size partition (fixed) called pages. Every process will have a separate page table. The entries in the page table are the number of pages a process. At each entry either we have an invalid pointer which means the page is not in main memory or we will get the corresponding frame number. When the frame number is combined with instruction of set D than we will get the corresponding physical address. Size of a page table is generally very large so cannot be accommodated inside the PCB, therefore, PCB contains a register value PTBR( page table base register) which leads to the page table.
具有固定大小分区的非连续策略称为分页。 一台计算机可以分配的内存量大于系统上实际安装的内存量。 该额外的内存实际上称为虚拟内存。 分页技术对于实现虚拟内存非常重要。 辅助内存分为称为页面的相等大小的分区(固定)。 每个进程将有一个单独的页表。 页表中的条目是一个进程的页数。 在每个条目中,要么我们有一个无效的指针,这意味着该页面不在主内存中,要么我们将获得相应的帧号。 当帧号与集合D的指令组合时,我们将获得相应的物理地址。 页表的大小通常很大,因此无法容纳在PCB内部,因此PCB包含一个指向页表的寄存器值PTBR(页表基址寄存器)。
Advantages: It is independent of external fragmentation.
优点:它独立于外部碎片。
Disadvantages:
缺点:
It makes the translation very slow as main memory access two times.
由于两次访问主内存,因此转换速度非常慢。
A page table is a burden over the system which occupies considerable space.
页表是占用相当大空间的系统的负担。
ii) Segmentation
ii)细分
Segmentation is a programmer view of the memory where instead of dividing a process into equal size partition we divided according to program into partition called segments. The translation is the same as paging but paging segmentation is independent of internal fragmentation but suffers from external fragmentation. Reason of external fragmentation is program can be divided into segments but segment must be contiguous in nature.
分段是存储器的程序员视图,在这里,不是将进程划分为相等大小的分区,而是根据程序将其划分为称为段的分区。 转换与分页相同,但分页分段与内部分段无关,但会遭受外部分段。 外部碎片的原因是程序可以分为多个段,但是段本质上必须是连续的。
iii) Segmentation with paging
iii)使用分页进行细分
In segmentation with paging, we take advantages of both segmentation as well as paging. It is a kind of multilevel paging but in multilevel paging, we divide a page table into equal size partition but here in segmentation with paging, we divide it according to segments. All the properties are the same as that of paging because segments are divided into pages.
在使用分页进行分段时,我们同时利用了分段和分页的优势。 这是一种多级分页,但是在多级分页中,我们将页表划分为相等大小的分区,但是在这里,在使用分页进行分段时,我们将其按段进行划分。 所有的属性都与分页的属性相同,因为段被分为页面。
翻译自: https://www.includehelp.com/operating-systems/contiguous-and-non-contiguous-memory-allocation.aspx
操作系统 非连续分配