七章节存储器管理.ppt

上传人:本田雅阁 文档编号:2328021 上传时间:2019-03-22 格式:PPT 页数:28 大小:1.80MB
返回 下载 相关 举报
七章节存储器管理.ppt_第1页
第1页 / 共28页
七章节存储器管理.ppt_第2页
第2页 / 共28页
七章节存储器管理.ppt_第3页
第3页 / 共28页
亲,该文档总共28页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《七章节存储器管理.ppt》由会员分享,可在线阅读,更多相关《七章节存储器管理.ppt(28页珍藏版)》请在三一文库上搜索。

1、第七讲 存储器管理,中国科学技术大学计算机系 陈香兰 2013Fall,内容提要,存储器的层次结构 程序执行的基础知识、程序的装入和链接 连续分配存储管理方式 分页存储管理方式 分段存储管理 段页式存储管理,存储器的层次结构,存储器是计算机系统的重要组成部分 容量、价格和速度之间的矛盾 内存、外存;易失性和永久性 内存,是稀缺资源 在现代计算机系统中,存储通常采用层次结构来组织 多级存储器结构 主存与寄存器 高速缓存和磁盘缓存,多级存储器结构,Storage systems in a computer system can be organized in a hierarchy Speed,

2、 access time Cost per bit Volatility,主存 vs. 寄存器,Same: Access directly for CPU Register name Memory address Different: access speed Register, one cycle of the CPU clock Memory, Many cycles (2 or more) Disadvantage: CPU needs to stall frequently & this is intolerable Remedy Cache,高级缓冲技术caching,Caching

3、 Copying information into faster storage system When accessing, first check in the cache, if In: use it directly Not in: get from upper storage system, and leave a copy in the cache Using of caching Registers provide a high-speed cache for main memory Instruction cache & data cache Main memory can b

4、e viewed as a fast cache for secondary storage ,Magnetic disks 磁盘,Transfer time 传输时间 TT data size * Transfer rate Transfer rate (n M/s)-1 ( n Byte/us )-1 1/n us/Byte Positioning time 定位时间 Seek time 寻道 Ts Rotational latency 旋转延迟 TR TP Ts +TR m ms TT VS. TP Please Store data closely,内容提要,存储器的层次结构 程序执行

5、的基础知识、程序的装入和链接 连续分配存储管理方式 分页存储管理方式 分段存储管理 段页式存储管理,程序执行的基础知识,Von Neumann architecture 冯诺依曼体系结构(图) Program must be brought into memory Main memory is usually too small Process Program must be placed within a process for it to be executed 作业池 User programs Where to place the program several steps(图),地址

6、的类型,Absolute address 绝对地址 Address seen by the memory unit Physical address 物理地址 Relative address 相对地址 Linear address 线性地址 Logical address 逻辑地址 Generated by the CPU Virtual address 虚拟地址 When can the absolute address can be decided?,Address binding 地址的绑定,Address binding 地址绑定, the binding of instructio

7、ns and data to memory, 可以在三种时刻进行 Compile time If memory location known a priori, absolute code can be generated; must recompile code if starting location changes. Load time Must generate relocatable code if memory location is not known at compile time. Execution time Binding delayed until run time i

8、f the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers),逻辑地址空间和物理地址空间,Logical address space 逻辑地址空间 The set of all logical addresses generated by a program Physical address space 物理地址空间 The set of all

9、physical addresses corresponding to theses logical addresses Logical = physical compile-time & load-time address-binding logical (virtual) != physical addresses execution-time address-binding MMU (hardware device),Memory-Management Unit (MMU),Hardware device, 逻辑地址 物理地址 Relocation register 重定位寄存器 Add

10、ed to every address generated by a user process at the time it is sent to memory E.g. MS-DOS on 80x86 User program deals with logical addresses, it NEVER sees the real physical addresses.,是否需要将进程的所有代码和数据一次性装入?,Shall we put the entire program & data of a process in physical memory before the process

11、can be executed? For better memory space utilization Dynamic loading Dynamic linking Overlays Swapping ,程序的装入,绝对装入方式 可重定位装入方式 动态运行时装入方式,绝对装入方式,编译时,产生absolute code,即使用绝对地址的代码 装入时,必须装入到指定的地址 无需对程序和数据的地址进行修改 适用于单道系统,可重定位装入方式,大多数情况下,不能预知装入地址,只能在装入时确定 编译时,产生可重定位代码,即使用相对地址的代码 装入时,必须重定位 通常把在装入时对目标程序中指令和数据的

12、修改过程称为重定位。 由于地址变换是在装入时一次性完成的,以后不再改变,故称为静态重定位 可用于多道系统,动态运行时重定位,有时候,程序会在内存中移动位置 例如对换 需要能支持在运行过程中动态改变程序在内存中的位置 方法:推迟重定位时机 即从相对地址到绝对地址的转换推迟到程序真正执行时才进行 因此,装入内存中的代码和数据的地址仍然是相对地址 需要重定位寄存器的支持,动态运行时装入方式,根据程序运行的局部性,让程序及其数据在需要时才被装入 Better memory-space utilization; unused routine is never loaded. Useful when la

13、rge amounts of code are needed to handle infrequently occurring cases Error routine No special support from OS is required implemented through program design Due to the users,Overlays 覆盖技术,Keep in memory only those are needed at any given time. Needed when process is larger than amount of memory all

14、ocated to it. Implemented by user, no special support needed from OS, programming design of overlay structure is complex,程序的链接,多个源程序编译多个目标模块;库。 需要链接成可装入模块 根据链接时间的不同 静态链接方式:装入前很早就链接 装入时动态链接:边装入,边链接 运行时动态链接:运行时才链接,静态链接方式,静态链接方式: 在程序运行之前,先将各目标模块以及它们所需要的库函数,链接成一个完整的装配模块,以后不再拆开。 各目标模块内:相对地址 存在目标模块之间的调用关系 外部调用符号 要解决的问题: 修改相对地址: 多个相对地址空间一个统一的相对地址空间 变换外部调用符号,装入时动态链接,在装入时,根据外部模块调用事件,使用装入程序去寻找相应的外部目标模块,并装入,在装入时,修改相对地址 优点: 便于修改和更新 便于实现对目标模块的共享,运行时动态链接,程序的每次运行,可能要执行的目标模块集是不同的 全部装入?按需装入? 运行时动态链接将对某些模块的链接推迟到程序执行时才进行 需要操作系统配合 优点:程序运行前的装入速度加快;省空间,作业:,从一个源程序到一个在内存中可执行的程序,一般需要哪几个步骤? 有哪几种地址类型? 有哪几种程序装入方式和链接方式?,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1