Principles of Operating Systems CS 446/646 3. Memory Management a. Goals of Memory Management b. Partitioning c. Linking & Loading 9 From object codes to executable in memory 9 Loading: binding logical references to physical addresses 9 Linking: weaving logical addresses together
d. Simple Paging & Segmentation e. Virtual Memory f.
10/13/2005
Page Replacement Algorithms
CS 446/646 - Principles of Operating Systems - 3. Memory Management
26
3.c Linking & Loading From object codes to executable
¾ Linkers and loaders 9 a linker or “link editor” is a program that takes a collection of object modules (created by compilers or assemblers) and combines them into a single executable program 9 a loader places the linked program in memory, possibly translating (relocating) addresses on the way Memory
program (Compiler or Assembler)
Loader Tanenbaum, A. S. (1999) Structured Computer Organization (4th Edition).
From source code to memory, via translating, linking and loading 10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
27
3.c Linking & Loading From object codes to executable
Tanenbaum, A. S. (1999) Structured Computer Organization (4th Edition).
Positioning modules before linking and loading 10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
28
3.c Linking & Loading From object codes to executable resolution of procedure reference & relocation
resolution of address reference & relocation by base shift + module size = 500
Tanenbaum, A. S. (1999) Structured Computer Organization (4th Edition).
relocation by base shift = 100
Linking and relocating 10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
29
3.c Linking & Loading Loading: binding logical references to physical addresses
¾ Loading involves binding instructions and data to physical memory addresses 9 once an executable is finished compiling or is stored on disk, the loader places it in memory 9 modern systems allow a user process image to reside in any part of physical memory 9 three approaches to loading: ' absolute loading = binding can be done beforehand, at compile time (writing once) $ relocatable loading = binding is done at load time (rewriting) & dynamic runtime loading = binding is postponed until execution time (not writing) 10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
30
3.c Linking & Loading Loading: binding logical references to physical addresses
' Absolute loading 9 requires that a given module always be loaded into the same location in memory 9 thus, the compiler can bind symbolic addresses directly to absolute addresses 9 this was the case of the .COM format programs in MS-DOS → not acceptable: prevents swapping and/or multitasking, etc.
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
Absolute load module
CS 446/646 - Principles of Operating Systems - 3. Memory Management
31
3.c Linking & Loading Loading: binding logical references to physical addresses
$ Relocatable loading 9 we need modules that can be located and relocated anywhere in memory 9 for this, the compiler must produce relative addresses 9 then the task of the loader is basically to add one or several fixed offset(s) to all address references 9 problem: swapping in and out requires delocating and relocating every time
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
Relocatable load module
CS 446/646 - Principles of Operating Systems - 3. Memory Management
32
3.c Linking & Loading Loading: binding logical references to physical addresses
& Dynamic runtime loading 9 physical address binding does not happen until the very last moment, when the instruction is executed 9 done by special processor hardware (combined with protection) 9 gives the most freedom Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
Hardware support for relocation 10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
33
3.c Linking & Loading Linking: weaving logical addresses together
¾ Static linking
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
34
3.c Linking & Loading Linking: weaving logical addresses together
¾ Dynamic load-time linking
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
35
3.c Linking & Loading Linking: weaving logical addresses together
¾ Dynamic runtime linking
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
36
Principles of Operating Systems CS 446/646 3. Memory Management a. Goals of Memory Management b. Partitioning c. Linking & Loading 9 From object codes to executable in memory 9 Loading: binding logical references to physical addresses 9 Linking: weaving logical addresses together
d. Simple Paging & Segmentation e. Virtual Memory f.
10/13/2005
Page Replacement Algorithms
CS 446/646 - Principles of Operating Systems - 3. Memory Management
37
Principles of Operating Systems CS 446/646 3. Memory Management a. Goals of Memory Management b. Partitioning c. Linking & Loading d. Simple Paging & Segmentation 9 Paging 9 Hardware support for paging 9 Segmentation
e. Virtual Memory f.
10/13/2005
Page Replacement Algorithms
CS 446/646 - Principles of Operating Systems - 3. Memory Management
38
3.d Simple Paging & Segmentation Paging
¾ (Sub)divide and conquer 9 new idea: partition process images, too, so that their physical domain doesn’t have to be contiguous anymore
memory is partitioned into small, equal-size chunks
process images or also subdivided into the same size chunks 9 the chunks of a process are called pages and chunks of memory are called frames
9 the O/S maintains a page table for each process
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
39
3.d Simple Paging & Segmentation Paging
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
40
3.d Simple Paging & Segmentation Paging
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
41
3.d Simple Paging & Segmentation Paging
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
42
3.d Simple Paging & Segmentation Paging
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
43
3.d Simple Paging & Segmentation Paging
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
44
3.d Simple Paging & Segmentation Hardware support for paging
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
45
3.d Simple Paging & Segmentation Hardware support for paging
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
46
3.d Simple Paging & Segmentation Hardware support for paging
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
47
3.d Simple Paging & Segmentation Segmentation
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
48
3.d Simple Paging & Segmentation Segmentation Logical
Tanenbaum, A. S. (1999) Structured Computer Organization (4th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
49
3.d Simple Paging & Segmentation Segmentation
Tanenbaum, A. S. (1999) Structured Computer Organization (4th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
50
3.d Simple Paging & Segmentation Segmentation
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
51
3.d Simple Paging & Segmentation Segmentation
must also have: offset < length
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
52
3.d Simple Paging & Segmentation Segmentation
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
53
3.d Simple Paging & Segmentation Segmentation
Silberschatz, A., Galvin, P. B. and Gagne. G. (2003) Operating Systems Concepts with Java (6th Edition).
10/13/2005
CS 446/646 - Principles of Operating Systems - 3. Memory Management
54
Principles of Operating Systems CS 446/646 3. Memory Management a. Goals of Memory Management b. Partitioning c. Linking & Loading d. Simple Paging & Segmentation 9 Paging 9 Hardware support for paging 9 Segmentation
e. Virtual Memory f.
10/13/2005
Page Replacement Algorithms
CS 446/646 - Principles of Operating Systems - 3. Memory Management
55