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.2 Timing of binding to memory(恐龙书9.1.2 Address binding)
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.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)
5.2 Implementation of page table
5.3 Effective Access Time (p367)
5.5 Hierarchical Paging(9.4.1)
5.7 Hashed Page Tables(恐龙书9.4.2)
5.8 Inverted page table(恐龙书9.4.3)
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

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