操作系统 非连续分配_操作系统中的连续和非连续内存分配

操作系统 非连续分配

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...

内存管理技术分为两部分...

  1. 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利用率非常差,因此使用了多程序。

  2. 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,而是进行上下文切换,然后选择另一个进程。

    1. Contiguous memory allocation
    2. 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.

在该固定大小的单个分区中分配一个进程。 但是,这将增加多程序化的程度,这意味着主内存中有多个进程限制了内存中固定分区的数量。 内部碎片的增加是由于连续的内存分配。

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

Non-contiguous memory allocation is of different types,

非连续内存分配类型不同,

  1. Paging

    分页

  2. Segmentation

    分割

  3. 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:

缺点:

  1. It makes the translation very slow as main memory access two times.

    由于两次访问主内存,因此转换速度非常慢。

  2. 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.

在使用分页进行分段时,我们同时利用了分段和分页的优势。 这是一种多级分页,但是在多级分页中,我们将页表划分为相等大小的分区,但是在这里,在使用分页进行分段时,我们将其按段进行划分。 所有的属性都与分页的属性相同,因为段被分为页面。

local view of segmentation

翻译自: https://www.includehelp.com/operating-systems/contiguous-and-non-contiguous-memory-allocation.aspx

操作系统 非连续分配

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

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

相关文章

文件名重定向到txt中Linux,Linux上glob用于实现文件名的通配、IO重定向及管道

Linux中所谓的通配是指,显示以指定条件为条件的文件;即通配的含义是指搜寻以已知条件为前提的目标文件。常用文件通配符有:文件通配符含义例子*任意长度的任意字符如a*,搜寻所有以a为首的文件名的文件?任意的单一字符如a&#xff…

分形与数据结构第二篇

一、分形之 迭代实现分形 本次的图形都是在之前的画图工具中实现的。 首先,还是和原来一样建立一个JButton元素组件,然后加上监听方法;再在public void mouseClicked(MouseEvent e) {}方法中实现图形; else if (s.equals("图…

python socket 大文件_python之socket运用之传输大文件

socket建议最大的传输单元是8192个字符,但是如果超过8192就会出现问题,我们可以用下面的方法处理客户端代码import subprocessimport socketip_bind ("127.0.0.1",9000)client socket.socket()client.connect(ip_bind)l1 []while True:opti…

华为linux版笔记本安装win7,华为MateBook X Pro笔记本怎样安装win7系统

华为MateBook X Pro的制造工艺达到了业界顶级的水准,高达91%的屏占比真正达到了近似全面屏的观感,触感顺滑质感强烈的机身让人爱不释手。对于有意选购一台高端轻薄本产品的消费者来说,MateBook X Pro应该是你首选的对象之一。那么这款笔记本怎…

横竖屏切换

单一控制器的横竖屏切换 if ([[UIDevice currentDevice] respondsToSelector:selector(setOrientation:)]) { SEL selector NSSelectorFromString("setOrientation:"); NSInvocation *invocation [NSInvocation invocationWithMethodSignature:[UIDevice instanceM…

怎么使用小爱同学音响_智能音响购买指南!!!

小度音响pro100天使用感受,100天前我冲动消费购买了一个智能音响,还是对比了多个智能音响做好的决定。使用到现在显然这个冲动消费是非常划算的,这个智能音响完全提升了我的生活质量,我现在一下班就会让它播放音乐、睡觉前播放几段…

达芬奇linux 与win,抛弃Linux:达芬奇软件WIN版安装及设置.doc

达芬奇软件Windows版本安装及设置指南注意事项:1. windows帐户名一定要是英文,否则安装过程中解压临时文件路径中有中文,安装会出错。如果帐户名是中文,需要在环境变量里面将用户环境变量的路径设为英文路径2. 这里我的安装路径都…

今天的几件琐事

最近发现突然忙了一些之后,很多事情都给耽误了,暂且称为拖延症吧。原本计划的很不错的学习计划,最近貌似也给耽误了不少,虽然每天回来会想今天写点什么,今天忙了些什么,发现好像今天的进步不大。因为离自己…

python做数学计算器_Python数学运算入门把Python当作计算器

Struts2 Interceptor学习Interceptor的设计思想,其实是Spring里面的AOP思想,尽管Struts2又有自己的Interceptor但是,在实际开发中,用的较少,SSH整合之后你可以采用AOP事务处理进行拦截,更 ...Mysql使用workbench迁移数据原文:http://jingyan.baidu.com/article/925f8cb8f3ec25c…

【分享】WeX5的正确打开方式(1)

最近在研究WeX5,想在这里记录下使用过程中的点滴,今天先把之前已经掌握的分享一下。WeX5官方的开发指南难度系数较大,面向的受众可能是已经敲过上万行代码的html5 app开发者。但是作为一个刚进入代码世界的html5 app开发宝宝,本人…

linux multipath.log,Linux Multipath配置

关于Linux Multipath配置,网上还是很多的,自己再来梳理一下,当前环境为RedHat6,HP P2000存储1. 安装软件。查看是否安装 rpm -qa |grep device-mapperdevice-mapper-multipath-libs-0.4.9-31.el6.x86_64device-mapper-event-libs-…

python文件封装成jar_【Python】Python文件打包为可执行文件

之前写的用于创建、链接Jenkins slave脚本是使用Python实现的,为了使未安装Python环境的伙伴也可以直接使用,故需要将其可直接执行的exe可执行文件。一、安装pyinsatller在cmd控制台输入以下命令进行安装。pip install pyinstaller二、使用pyinstaller打…

svn , github工作流

svn 需要有一台中央服务器,所有的分支,主干,标签,全都保存在这台中央服务器上。开发着需要提交代码时,需要保持中央服务器连接。切换分支时会有本地与服务器网络连接。 git 改进了这一点,每台安装有git的机…

linux控制流程,Linux - Bash - 流程控制

sh的流程控制不可为空,不能什么都不能做,不能像php这样:if (isset($_GET["q"])) {search(q);}else {// 不做任何事情}在sh/bash里可不能这么写,如果else分支没有语句执行,就不要写这个else。if elseifif语句语法格式&am…

python文本词频统计是什么_python 大批量文本分词 以及词频统计 (高效处理案例)...

环境:python3.6库:jieba,xlwt,xlwings,collections前两天有个需求要对一张表里的中文语句进行分词,并统计每个词语出现的次数。表格1231.xlsx大致内容如下:由于表格内容过大,约有100…

c语言字符串匹配函数index,C语言(函数)学习之index、rindex

函数定义:char *index(const char *s, int c);头文件: #include strings.h函数说明:index()用来找出参数s 字符串中第一个出现的参数c 地址,然后将该字符出现的地址返回。字符串结束字符(NULL)也视为字符串一部分。返回值&…

JZ-C-35

剑指offer第三十五题&#xff1a;第一个只出现一次的字符 1 //2 // Name : JZ-C-35.cpp3 // Author : Laughing_Lz4 // Version :5 // Copyright : All Right Reserved6 // Description : 第一个只出现一次的字符7 //8 9 #include <iostream> 10 #incl…

过滤器,绑定事件,动画

一、基本过滤器 语法描述返回值:first选取第一个元素单个元素:last选取最后一个元素单个元素:not(selector)选取去除所有与给定选择器匹配的元素集合元素:even选取索引是偶数的所有元素(index 从0开始)集合元素:odd选取索引是奇数的所有元素(index 从0开始)单个元素:eq(index)选…

一周学好python_耗时一周整理的Python资料,包含各阶段所需网站、项目,收藏了?慢慢来...

不知怎么的&#xff0c;最近不少关注我的读者都开始私信我怎么学好python&#xff1f;零基础转行是不是合适&#xff0c;还有希望吗&#xff1f;今年30了&#xff0c;还能不能转IT&#xff1f;今天这篇文章&#xff0c;我花了一周的时间搜索、整理、调研、筛选&#xff0c;最后…

python中bool函数的用法_python3实战python函数每日一讲 - bool([x])

bool([x])英文说明&#xff1a;Convert a value to a Boolean, using the standard truth testing procedure. If x is false or omitted, this returns False; otherwise it returns True. bool is also a class, which is a subclass of int. Class bool cannot be subclasse…