Final Flashcards
What is the main purpose of memory management?
To control and coordinate computer memory by assigning portions called blocks to various processes to improve system performance.
What are the roles of base and limit registers?
In order to protect the memory we need to ensure that a process can only access addresses in it’s address space. The base and limit registers define the logical address space of a process to provide this protection.
How are hardware addresses protected?
CPU must check every memory access generated in user mode to be sure it is between base and limit for that user.
-Instructions to load the base and limit registers are privileged.
What are the different stages of binding instructions 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 if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps
What is the difference between absolute code and relocatable code?
Absolute code is placed exactly where you tell the assembler it will be.
Relocatable code means that the code can be placed anywhere that there is room for it.
What is the difference between logical and physical address space
Logical Address - Generated by the CPU, also known as a virtual address. LA Space is the set of all logical addresses generated by a program.
Physical Address - Address seen by the memory unit. PA space is the set of all physical addresses generated by a program.
The addresses are the same in compile-time and load-time address-binding schemes, but differ in execution-time address binding schemes.
What is the MMU?
The Memory-Management Unit is a hardware device that maps virtual addresses to physical addresses at runtime.
What is a simple MMU scheme?
The value in the relocation register (this is what the base register is now called) is added to every address generated by a user process at the time it is sent to memory.
The user program deals with logical addresses, and never sees the real physical addresses.
What is dynamic loading?
The entire program does not need to be in memory to execute. Routine is not loaded until it is called.
Better memory-space utilization; unused routine is never loaded.
What is static linking?
System libraries and program code combined by the loader into the binary program image
What is dynamic linking?
Linking is postponed until execution time. Particularly useful for libraries.
What is a stub?
A small piece of code, used to locate the appropriate memory-resident library routine.
What is contiguous allocation?
Main Memory must support both OS and user processes with limited resources. Contiguous allocation is one early method.
Usually MM is split into two partitions where resident operating system usually held in low memory with interrupt vector and user processes held in high memory. Each process contained in single contiguous section of memory.
What is multiple-partition allocation?
Variable-partition sizes for efficiency (sized to a given process’ needs)
A hole is a block of available memory. When a process arrives it is allocated memory from a hole large enough to accommodate it.
Process exiting frees its partition and adjacent free partitions are combined.
OS maintains information about allocated partitions and free ones (holes).
What are the methods of dynamic storage allocation?
How to satisfy a request of size n from a list of free holes?
First-fit: The first hole that is big enough
Best-Fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. (Leaves smallest leftover hole)
Worst-fit: Allocated the largest hole; must also search the entire list (Leaves largest leftover hole)
What are the types of fragmentation?
External Fragmentation - Total memory space exists to satisfy a request but it is not contiguous.
Internal Fragmentation - Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.
What is compaction?
Compaction aims to reduce external fragmentation.
- Shuffles memory contents to place all free memory together in one large block
- Possible only if relocation is dynamic and done at execution time
- I/O problem - Latch job in memory while it is involved in I/O. Do I/O only into OS buffers.
What is paging?
Physical address space of a process can be non-contiguous; process is allocated physical memory whenever the latter is available which avoids external fragmentation and the problem of varying sized memory chunks.
How does paging work?
Memory is divided into fixed-size blocks called frames whose size is a power of 2 (512 bytes to 16Mbytes)
Logical memory is divided into blocks of the same size called pages.
All frames are kept track of, and running a program of size N pages requires N free frames.
Still has internal fragmentation.
What is the address translation scheme?
Address generated by CPU is divided into: page number (p) - Used as an index into a page table which contains base address of each page in physical memory page offset (d) - Combined with base address to define the physical memory address that is sent to the memory unit.
How is internal fragmentation calculated with paging?
Page size - n bytes
Process size - m bytes
Internal fragmentation = n - (m % n)
Smaller pages = less internal fragmentation, but each page takes memory to track.
How is the page table implemented?
Page-table base register (PTBR) points to the page table
Page-table length register (PTLR) indicates the size of the page table
In this scheme every data/instruction access requires two memory accesses, one for the page table and one for the data / instruction