Week 6 Flashcards
Crt.o
At link time, linker knows crt.o goes at the beginning of memory. Defines point where OS will begin executing the program usually with a name call entry. crt.o will call main. It contains variables and code. Code from crto.o goes to the beginning of the text segment and contains the exit hook.
File copied after crt.o
Foo.o copies code segment after crt.o and then bar.o goes after foo.
Follows process added processes in memory
Needed libraries for the code. Linker goes into the library and adds the stack and code files.
Fixing unresolved chains
Crt.o has undefined references to main and exit. Linker sets up code to point to where main and exit actually are (foo and stdi.o). Go through foo.o code to link fopen, etc to stdio.o. Go through bar.o to link unresolved. If every symbol is resolved, the linker is done. If not, the linker will throw an error.
Logical address space
Address generated by CPU
Physical Address Space
Location in physical memory
Logical vs physical on binding
Compile and load time have the same binding. Execution time these addresses differ.
MMU
Memory management unit. In between Ram and Cpu, maps virtual addresses to physical addresses.
Relocation register
Register added to every virtual address space
MMU process
CPU generates logical address. Checks address against limit register to ensure address is within range. Add relocation register. End with physical address in memory.
Advantage of MMU
serves as memory protection for physical memory.
Contiguous memory
One block of memory allocated to a full program.
IBM Memory setup
Segments large enough to run biggest possible program
How are holes managed
OS keeps track of holes. OS will find hole big enough to fit process. When a process ends, its added to the free list.
First fit
Use first hole that fits size requirement for process. Advantage: Only have to look at list until size is found (where we left off from the last look through)
Best Fit
Find the smallest hole that can fit. Advantage: - Minimum amount of waste. Disadvantage: Search entire list and end up with tiny slivers
Worst fit
Look for largest block. Advantage: End up with big blocks. Disadvantage: Worst algorithm to use (it dumb).
Internal Fragmentation
Allocate memory in larger in general sized blocks. Extra memory in the block that’s useless.
External Fragmentation
Small holes spread through memory which none are big enough to satisfy a request.
Fragmentation trade - Allocate in smaller units
Less internal fragmentation but more overhead in managing allocation
Fragmentation trade - Allocate in larger units
Easier to manage, more internal fragmentation
50 percent rule
Of N allocated blocks, 0.5 N space is lost to fragmentation. Only 1/3 of memory is usable
Dynamic Loading
Only load routines when needed as memory is in short supply. Doesn’t require OS support. Applied in IBM, mainframe, JAVA Vm
Static Linking
Take full program and load it. Like in example with loading foo and bar.