Memory Management Flashcards
(96 cards)
Explain the concept of a memory hierarchy
Few MB of volatile quickly accessible expensive cache memory
Few GB of volatile medium speed medium expense main memory
Few TB of nonvolatile slow speed cheap disk memory
(May also have removable storage)
How can multiple programs be run at the same time with no memory abstraction?
OS saves entire contents of memory to a disk file then brings in and runs next program. This works so long as there is only one program in memory at a time.
Explain memory addresses
A memory address is a memory abstraction. These are fixed length sequences of digits. This means memory location 28 in 1 program will be different to that in the memory address of another
What are the base and limit registers used for? What is a disavantage?
Base register contains the physical address where program begins in memory (tells you how far offset actual address is_ and limit register has the length of the program. Access is aborted if memory trying to be accessed is greater than or equal to limit register. The disadvantage is having to perform addition and comparison on every memory address.
What approaches have been developed to deal with memory overload?
1) swapping: bringing each process into memory in its entirety, running for a time then swapping it out
2) virtual memory: allows programs to run even when they are only partially in main memory
Explain swapping
Bringing each process into memory in its entirety, running for a time then swapping it out to disk. If a dynamically sized process needs more space, but cannot grow and swap area on disk is full, this process will have to be temporarily suspended or killed
Is memory compaction done often?
No, as it requires a lot of CPU time
Who manages dynamically assigned memory?
The OS
How can we keep track of memory usage?
1) Bitmap
2) Free lists
Explain memory management with bitmaps. What is the disadvantage of them?
Memory is divided into allocation units with each unit having a corresponding bit (0 if free, 1 if full or vice versa).
The disadvantage is that if something of size k units enters, k consecutive 0 bits must be found which is a long operation
Explain memory management with linked lists
Each entry in the linked list is either a hole or a process (H or P). These are sorted by address. Multiple holes in a row are combined into one.
Explain the first fit algorithm
Memory manager scans along until a hole of big enough size is found. This is fast as limited searching needs to be done
Explain the next fit algorithm
This starts searching the list at the place it last left off, rather than the start, to find a hole of big enough size
Explain the best fit algorithm
Best fit searches entire list and takes the smallest adequate hole. Best fit is slower than first fit as it searches entire list. This results in wasted memory as it leaves lots of little holes, which nothing can fit in. Best fit and first fit can be same time if the list is only a list of holes (not processes)
Explain the worst fit algorithm
Worst fit searches entire list and takes biggest hole, such that breaking it up will cause large holes to be left.
Explain the quick fit algorithm
Maintains separate lists for holes of different but common sizes. Merges can be expensive
What are the memory allocation algorithms?
1) First fit
2) Next fit
3) Best fit
4) Worst fit
5) Quick fit
What solutions are available to the problem of having programs larger than memory?
1) Breaking programs into overlays
2) Virtual memory
Explain the concept of virtual memory
Only parts of program have to be in main memory at once.
Each program has an address space broken into chunks (contiguous range of addresses) called pages. Pages are mapped onto physical memory, but not all pages have to be in memory to run. When program references part of address space that isn’t in physical memory, the OS will retrieve this piece and reexecute instruction after a page fault occurs.
This means that pages do not have to be in contiguous memory sections themselves.
This is the illusion that the user has all of the memory for their process. This should solve the problem of external fragmentation
Explain paging
This is a technique used by virtual memory systems. In this, pages are stored on disk and retrieved by OS in the case of a page fault when required. Whole pages must be sent, not parts.
What are virtual addresses?
Each program has a virtual address space
What happens to virtual addresses on computers without virtual memory? What about computers with virtual memory?
Without: Virtual address is put directly onto memory bus, causing physical memory word with same address to be read/written
With: Virtual address goes to MMU that maps virtual addresses onto physical memory addresses
With 64KB of virtual address space and 32KB of physical memory, if we get 16 virtual pages, how many page frames will there be?
- This means only 8 of the virtual pages are mapped onto physical memory at a time. Present/absent bit keeps track of which pages are physically present in memory.
What does the present/absent or valid bit do?
Present/absent bit keeps track of which pages are physically present in memory in the case of virtual memory being used