操作系统 ShanghaiTech CS130 | Main memory

ShanghaiTech CS130 | Lecture Note 02 | Main memory

Topic: memory management algoirhtms, paging, segmentation

Keyword: paging, fragmentation, swapping, sharing, protection

说明:笔记旨在整理我校CS130课程的基本概念。由于授课及考试语言为英文,故用英文为主,中文为辅的方式整理。由于是整理,尽提供最低限度的解释,以便提供简洁快速的查阅。

全部笔记索引:【传送门】 | 上一节: Scheduling  | 下一节: Virtual Memory

目录

ShanghaiTech CS130 | Lecture Note 02 | Main memory

1 Names and Binding

1.1 Definition of names

1.2 Timing of binding to memory(恐龙书9.1.2 Address binding)

1.3 Dynamic Loading(恐龙书9.1.4)

1.4 Dynamic Linking(恐龙书9.1.5)

1.5 Overlay

2 Logical vs. Physical address(恐龙书9.1.3)

2.1 priminal defintion of logical address and physical address

2.2 Memory Mangement Unit (MMU)

3 Swapping(恐龙书9.5)

3.1 常见术语

3.2 Implementation convention

3.3 Context switch time including swapping

4 Contiguous Allocation(恐龙书9.2)

4.1 Single-partition allocation vs. Multiple-partitoin allocation

4.2 Dynamic storage allocation(恐龙书9.2.2)

4.3 Fragmentation(恐龙书9.2.3)

5 Paging(恐龙书9.3)

5.1 Basic ideas(9.3.1)

5.2 Implementation of page table

5.3 Effective Access Time (p367)

5.4 Memory Protection(9.3.3)

5.5 Hierarchical Paging(9.4.1)

5.6 ASID

5.7 Hashed Page Tables(恐龙书9.4.2)

5.8 Inverted page table(恐龙书9.4.3)

5.9 Paging and Copy on write

6 Paging advanced topics

6.1 Shared Pages

6.2 Segmentation

7 Examples

7.1 Intel A-32

7.2 Linux on Pentium

Reference


1 Names and Binding

1.1 Definition of names

Symbolic->Logical->Physical names

Def: Symbolic names: known in a context or path

  • file names, program names, printer/device names, usernames

Def: Logical names: used to label a specific entity

  • inodes, job number, major/minor device number, pid, uid, gid, ...

Def: Physical names: address of entity

  • inode address on disk or memory, entry point or variable address, PC address

1.2 Timing of binding to memory(恐龙书9.1.2 Address binding)

1.Intuition: bind symbolic address(variable name) to some address. CA(computer architecture) has taught us that a complier binds the symbolic address to relocatable address. The linker or loader in turn binds the relocatable addresses to absolute address. Each binding is a mapping from one address space to another.

2. Binding occurs at 3 different stages:

  • Compile time
    • Generate absolute code
    • Must recompile code if starting location changes
  • Load time
    • Must generate relocateable code
  • Execution time
    • Binding delayed until runtime(process can be moved during its execution)
    • Need HW support for address maps

3. Binding time tradeoffs

  • Early binding(At compile time)
    • Compiler: produces efficient code
    • Allows checking to be done early
    • Allows estimates of running time and space
  • Delayed binding(at load time)
    • linker, loader
    • produces efficient code, allows separate compliation(for library)
    • portability and sharing of object codes
  • Late binding
    • VM, dynamic linking/loading, overlaying, interpreting
    • code less efficient, checks done at runtime
    • flexible, allows dynamic reconfiguration
bind时间图示

1.3 Dynamic Loading(恐龙书9.1.4)

Def: Routine is not loaded until it is called. All routines are kept on disk in a relocatable load format.

Pros: Better memoery-space utilization. Unused routine is never loaded. Useful when large code, infrequently

Cons: No special support from OS. Implemented through program design(by providing library routines).

1.4 Dynamic Linking(恐龙书9.1.5)

Def: Linking postponed until execution time, can be shared among processes (like C std library).

Introduction to stub: to locate the memory-resident library routine. stub replaces itself with the address of the routine, and executes the routine. OS needed to check if routine in memory.

1.5 Overlay

WIKI

the process of transferring a block of program code or other data into main memory, replacing what is already stored

Keep in memory only needed. The policy is implemented by user and complex, due to the issue that process is too large. 

2 Logical vs. Physical address(恐龙书9.1.3)

2.1 priminal defintion of logical address and physical address

Def: Logical address generated by CPU.

Def: Physical address seen by memory unit.

Same when compiling and load-time binding.

Differs in execution-time address-binding(due to efficient implementation of memory loading policy). Therefore, it is "fake" w.r.t. real address in memory unit. we call it virtual address.

2.2 Memory Mangement Unit (MMU)

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值