这是我参与「第五届青训营 」笔记创作活动的第14天
C8 Main Memory
logical vs. physical memory
How to satisfy a request of size n from a list of free holes: First-fit Best-fist Worst-fit Next-fit scans memory from
How to slove dynamic storage allocation problem?
External Fragmentation?
Internal Fragmentation?
What is paging?
Logical address space of a process can be noncontiguous;process is allocated pyhsical memory whenever the latter is available. Divide pyhsical memory into fixed-sized blocks called frames Size is power of 2 Typically have small pages(1k-16k) Divide logical memory into blocks of same size called pages.
What is page table and TLB(a translation lookaside buffer is a memoey cache that is used to reduce time)?
page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and pyhsical addresses.
What is segmentation? t scheme that supports user view of memory. a program is a collection of segments.
A segment is a logical unit such as: main program, procedure, function, local variables,global variables, stack, ......
C9 virtual memory
Virtual memory separation of user logical memory from physical memory Page fault:何时发生 引用主存当中不存在的页面导致出错
1.operation system looks at another table to decide
①Invaild reference->abort ②Just not in memory
2.get empty frame
3.swap page into frame
4.reset tables
5.set validation bit = v
page replacement 在内存中找到一些页面,但是没有真正使用,将其替换。
1.find the location of the desired page on disk
2.find a free frame
①If there is a free frame use it ②If there is no free frame,use a page replacement algorithm to select a victim frame
3.Bring the desired page into the newly free frame;update the page table
4.Restart the process
How do the page replacement algorithms work?
FIFO Throw out oldest page/
OPT/MIN(replace page that won't be used for the longest time)
Where will D be brought in?Look for the page not referenced farthest in the future.
LRU(Least Recently Used,Replace page that hasn't been used for the longest time)
Page hasn't been used for the longest time.
Thrashing
Thrashing=a process is busy swapping pages in and out.
C10 &&C11 File System
File system:Layer of OS that transforms block interface of disks(or other block devices) into Files.Directories,etc. File: user-visible group pf blocks arranged sequentially in logical space (file is a collection of blocks) Directory:user-visible index mapping names to files(later)
How to organize files on disk?
Continuous Allocations
Linked List Approach
Each block,pointer to next on disk
File Allocation Table(FAT)
多级索引文件 (multilevel indexed files)
How to manage free space on disk?
Linked Free Space List Bit map Grouping Counting