1
CSC 4103 - Operating Systems Spring 2007
Tevfik Koşar
Louisiana State University
March 8th, 2007
Lecture - XII
Main Memory - II
2
Roadmap
- Dynamic Loading & Linking
- Contiguous Memory Allocation
- Fragmentation
- Paging
- Segmentation
3
Dynamic Loading
- Used to increase memory space utilization
- A routine is not loaded until it is called
– All routines do not need to be in memory all time – Unused routines never loaded
- Useful when large amounts of code are needed to handle
infrequently occurring cases
- No special support from the operating system is required to
implement
- When a routine needs to call another routine:
– Caller first checks if that routine is already in memory – If not, loader is called – New routine is loaded, and program’s address tables updated
4
Dynamic Linking
- Linking postponed until execution time
- Otherwise each program should have a copy of its language
library in its executable image
- Small piece of code, stub, used to locate the appropriate
memory-resident library routine or how to load it
- Stub replaces itself with the address of the routine, and
executes the routine
- The next time, library routine is executed directly, without
need to reload
- All processes that use a language library execute only one copy
- f the library code
- Also useful for library updates and bug fixes
- Dynamic linking requires support from OS
5
Swapping
- A process must be in memory for execution
- A process can be swapped temporarily out of
memory to a backing store, and then brought back into memory for continued execution
- Backing store – fast disk large enough to
accommodate copies of all memory images for all users; must provide direct access to these memory images
- Roll out, roll in – swapping variant used for
priority-based scheduling algorithms; lower- priority process is swapped out so higher-priority process can be loaded and executed
6