Memory Flashcards
CPU can only address process where
main memory and registers
cannot address I/O or hard disk
CPU time to access GPR versus main memory
GPR 1 clock tick, 1 cycle (1/f)
Cache between main memory and registers
Main memory 4-20 cycles
CPU to main memory taking many cycles can cause a stall
CPU needs instructions every cycle or it will stall
CPU addressable memory
16 bit addresses 2^16 = 64k memory
2^20 = 1 M memory
2^22 = 4M
32 bit addresses 2^32 = 4 GB
RISC
Reduced instruction set computer 1 cycle per instruction
Contiguous memory allocation for a process (base/limit registers)
Implemented in OS with the help of two registers, the base and limit registers. When a process is executing in main memory, its base register contains the starting address of the memory location where the process is executing, while the amount of bytes consumed by the process is stored in the limit register. A process does not directly refer to the actual address for a corresponding memory location. Instead, it uses a relative address with respect to its base register. All addresses referred by a program are considered as virtual addresses. The CPU generates the logical or virtual address, which is converted into an actual address with the help of the memory management unit (MMU). The base address register is used for address translation by the MMU. Thus, a physical address is calculated as follows:
Physical Address = Base register address + Logical address/Virtual address
CPU generates what kind of addresses
Logical (also known as virtual)
Not physical - physical is address seen by memory unit
old - preserve contiguous property of program or jumps will fail (not true now)
Address binding of instructions and data to memory - types
Compile time - absolute; must recompile if address changes (static binding)
Load time - relocatable code; space interval same but start (base) may be different (moved base and limit)
Execution time - can be moved from one memory segment to another (dynamic binding)
DLL dynamic link libraries have addresses in some other module
Memory Management Unit (MMU)
Hardware device that maps virtual to physical address
Value in relocation register is added to address generated by a user process at the time process is sent to memory
CPU —-logical addr – MMU — physical addr —- memory
relocation
register
Static vs dynamic linking
Static - sys library and prgm code combined by loader into bin prgn image (compile - link - load)
Dynamic - not linked until execution time
small piece of code, stub is placeholder for libr routine
Swapping
process swapped in and out of memory to temp space on disk
Context switching, as related to swapping
Total time = time ut + time in
Structured program language evolved to
Object oriented programming (OOP)
Malloc - memory allocation
Memory map:
0 1000
X hole
500
x hole
5000
9999
MMU maps dynamically
shuffle to come up with 7000 free contiguous memory
Dynamic Storage Allocation Problem (for contiguous memory space)
How to satisfy a request of size N from list of free holes
- First fit - allocate first hole that is big enough
- Best fit - allocate smallest hole that is big enough (must search entire list, unless ordered)
- Worst fit - allocate the largest hole (also must search entire list)
produces largest leftover hole
First and best better for speed and storage utilization
Fragmentation definition and types
Def - holes in memory space not used
Types - External: pieces everywhere, not contiguous
Internal: allocated > requested
size difference internal to a partition