CS 134: Operating Systems
Process Execution
1 / 34
CS 134: Operating Systems
Process Execution
2013-05-19
CS34
CS 134: Operating Systems Process Execution 1 / 34 Overview CS34 - - PowerPoint PPT Presentation
CS34 2013-05-19 CS 134: Operating Systems Process Execution CS 134: Operating Systems Process Execution 1 / 34 Overview CS34 Overview 2013-05-19 Patch Peer Review Programs, Memory, & Address Space Overview Running a Program
Process Execution
1 / 34
CS 134: Operating Systems
Process Execution
2013-05-19
CS34
Patch Peer Review Programs, Memory, & Address Space Running a Program Filling Memory Selecting Space Memory Sharing
2 / 34
Overview
Patch Peer Review Programs, Memory, & Address Space Running a Program Filling Memory Selecting Space Memory Sharing
2013-05-19
CS34 Overview
Patch Peer Review
Group Clarity Concise Fit Correct Docs Total fax 4.22 4.78 4.56 4.11 4.67 22.34 ewes 3.67 4.67 4.67 3.67 4.33 21.01 biker 4.33 4.67 4.00 3.33 4.67 21.00 nigh 4.33 4.67 5.00 3.33 3.67 21.00 loan 3.67 4.33 4.33 3.67 4.33 20.33 eat 5.00 4.33 3.67 2.00 4.67 19.67 fakes 3.67 3.67 4.00 3.33 5.00 19.67 gates 4.33 3.33 4.00 2.33 5.00 18.99 loop 4.67 3.67 4.67 2.67 2.67 18.35 halos 3.67 3.67 3.00 4.00 4.00 18.34
3 / 34
Numeric Evaluations
Group Clarity Concise Fit Correct Docs Total fax 4.22 4.78 4.56 4.11 4.67 22.34 ewes 3.67 4.67 4.67 3.67 4.33 21.01 biker 4.33 4.67 4.00 3.33 4.67 21.00 nigh 4.33 4.67 5.00 3.33 3.67 21.00 loan 3.67 4.33 4.33 3.67 4.33 20.33 eat 5.00 4.33 3.67 2.00 4.67 19.67 fakes 3.67 3.67 4.00 3.33 5.00 19.67 gates 4.33 3.33 4.00 2.33 5.00 18.99 loop 4.67 3.67 4.67 2.67 2.67 18.35 halos 3.67 3.67 3.00 4.00 4.00 18.34
2013-05-19
CS34 Patch Peer Review Numeric Evaluations
Patch Peer Review
Rank Group 1.50 loan 1.67 fax 2.25 fakes 2.33 ewes 2.33 nigh 3.00 biker 3.00 halos 3.33 eat 3.50 gates 3.50 loop
4 / 34
Ranking
Rank Group 1.50 loan 1.67 fax 2.25 fakes 2.33 ewes 2.33 nigh 3.00 biker 3.00 halos 3.33 eat 3.50 gates 3.50 loop
2013-05-19
CS34 Patch Peer Review Ranking
Programs, Memory, & Address Space Running a Program
What transformations does the C source below need go through to become a running process? int main() { write(1, "Hello, world\n", 13); return 0; }
5 / 34
Background—How Processes Get into Memory Class Exercise:
What transformations does the C source below need go through to become a running process? int main() { write(1, "Hello, world\n", 13); return 0; }
2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Background—How Processes Get into Memory
Programs, Memory, & Address Space Running a Program
.rdata LC0: .ascii "Hello World\n\000" .text main: addiu sp,sp,-24 # Set up stack frame for main la a1,LC0 # Params for write: a0 = 1, a1 = address li a0,1 # of "Hello world" string, and a2 = 12 sw ra,16(sp) # Save our return address (jal overwrites) jal write # Call write li a2,13 # Delay slot! Executed BEFORE instr above! lw ra,16(sp) # Restore our return address move v0,0 # Our return value is zero jr ra # Adjust stack and return to caller addiu sp,sp,24 # Delay slot! Executed BEFORE instr above! nop
6 / 34
Assembly code—helloworld.s
.rdata LC0: .ascii "Hello World\n\000" .text main: addiu sp,sp,-24 # Set up stack frame for main la a1,LC0 # Params for write: a0 = 1, a1 = address li a0,1 # of "Hello world" string, and a2 = 12 sw ra,16(sp) # Save our return address (jal overwrites) jal write # Call write li a2,13 # Delay slot! Executed BEFORE instr above! lw ra,16(sp) # Restore our return address move v0,0 # Our return value is zero jr ra # Adjust stack and return to caller addiu sp,sp,24 # Delay slot! Executed BEFORE instr above! nop2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Assembly code—helloworld.s
Programs, Memory, & Address Space Running a Program
Contents of section .text: 0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 Contents of section .data: Contents of section .rodata: % Hello World..... 0000 48656C6C 6F2C2077 6F726C64 0A000000
7 / 34
Object code—helloworld.o
Contents of section .text: 0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 Contents of section .data: Contents of section .rodata: % Hello World..... 0000 48656C6C 6F2C2077 6F726C64 0A000000
2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Object code—helloworld.o
The .rodata contains "Hello, world\n"
Programs, Memory, & Address Space Running a Program
Contents of section .text:
0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 27BDFFE8 addiu sp,sp,-24 3C050000 lui a1,0 24A50000 addiu a1,a1,0 24040001 li a0,1 AFBF0010 sw ra,16(sp) 0C000000 jal 2406000C li a2,12 8FBF0010 lw ra,16(sp) 00001021 move v0,0 03E00008 jr ra 27BD0018 addiu sp,sp,24 00000000 nop
8 / 34
Object code—helloworld.o
Contents of section .text: 0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 27BDFFE8 addiu sp,sp,-24 3C050000 lui a1,0 24A50000 addiu a1,a1,0 24040001 li a0,1 AFBF0010 sw ra,16(sp) 0C000000 jal 2406000C li a2,12 8FBF0010 lw ra,16(sp) 00001021 move v0,0 03E00008 jr ra 27BD0018 addiu sp,sp,24 00000000 nop
2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Object code—helloworld.o
Programs, Memory, & Address Space Running a Program
Contents of section .text: 0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 Relocation records for section .text: Type Value 0004 R_MIPS_HI16 .rodata 0008 R_MIPS_LO16 .rodata 0014 R_MIPS_26 write
9 / 34
Object code—helloworld.o
Contents of section .text: 0000 27BDFFE8 3C050000 24A50000 24040001 0010 AFBF0010 0C000000 2406000C 8FBF0010 0020 00001021 03E00008 27BD0018 00000000 Relocation records for section .text: Type Value 0004 R_MIPS_HI16 .rodata 0008 R_MIPS_LO16 .rodata 0014 R_MIPS_26 write
2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Object code—helloworld.o
Programs, Memory, & Address Space Running a Program
Link with libc.a and crt0.o
◮ crt0.o contains startup code ◮ libc.a contains code for write
◮ Note no dynamic/shared library support yet!
◮ Linker can resolve the relocation entries ◮ End result is an executable, or load image.
The OS still needs to:
◮ Decide if it has resources to run the program right now
(long-term scheduler)
◮ Decide where to put the program in memory ◮ Perform any additional setup ◮ Start executing the program
10 / 34
Executable code—helloworld
Link with libc.a and crt0.o
◮ crt0.o contains startup code ◮ libc.a contains code for write ◮ Note no dynamic/shared library support yet! ◮ Linker can resolve the relocation entries ◮ End result is an executable, or load image.The OS still needs to:
◮ Decide if it has resources to run the program right now(long-term scheduler)
◮ Decide where to put the program in memory ◮ Perform any additional setup ◮ Start executing the program2013-05-19
CS34 Programs, Memory, & Address Space Running a Program Executable code—helloworld
Programs, Memory, & Address Space Filling Memory
User Space
(768 KB)
OS
(256 KB)
Only one process—can always locate running process in same place
◮ Static linking ◮ Loading is easy
What is the easiest way to retrofit this model to run a second program when the first one has to wait for a while?
11 / 34
Uniprogramming OS
User Space
(768 KB)OS
(256 KB)Only one process—can always locate running process in same place
◮ Static linking ◮ Loading is easyClass Exercise
What is the easiest way to retrofit this model to run a second program when the first one has to wait for a while?
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Uniprogramming OS
Programs, Memory, & Address Space Filling Memory
Add swapping to uniprogramming OS:
(768 KB)
(256 KB)
Swap out Swap in
12 / 34
Simple Multiprogramming, using Swapping
Add swapping to uniprogramming OS: User Space (768 KB) OS (256 KB) P1 P2 Swap out Swap in
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Simple Multiprogramming, using Swapping
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(384 KB)
Process 2
(384 KB)
Process 3
(384 KB)
Add more memory, to allow multiple processes
13 / 34
Fixed Partitioning
OS (256 KB) Process 1 (384 KB) Process 2 (384 KB) Process 3 (384 KB)Add more memory, to allow multiple processes
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Fixed Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(384 KB)
Process 2
(384 KB)
Process 3
(384 KB)
Add more memory, to allow multiple processes But
◮ Processes don’t have a fixed address in memory ◮ Loading must deal with relocation?
13 / 34
Fixed Partitioning
OS (256 KB) Process 1 (384 KB) Process 2 (384 KB) Process 3 (384 KB)Add more memory, to allow multiple processes But
◮ Processes don’t have a fixed address in memory ◮ Loading must deal with relocation?2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Fixed Partitioning
Programs, Memory, & Address Space Filling Memory
Remember when we talked about protection?
base limit logical addr.
+ <
Memory TRAP
Add base register to user addresses
◮ Logical address—used by program ◮ Physical address—actual address in physical memory
14 / 34
Runtime Relocation—Hardware to the rescue
Remember when we talked about protection?
Processor
base limit logical addr. + < Memory TRAPAdd base register to user addresses
◮ Logical address—used by program ◮ Physical address—actual address in physical memory2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Runtime Relocation—Hardware to the rescue
Programs, Memory, & Address Space Filling Memory
Position-independent code: either
◮ Grab a register to use as our “base” register and add or
subtract from that, or
◮ Calculate address based on current program counter
15 / 34
Runtime Relocation—Software alternative
Position-independent code: either
◮ Grab a register to use as our “base” register and add orsubtract from that, or
◮ Calculate address based on current program counter2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Runtime Relocation—Software alternative
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(384 KB)
Process 2
(384 KB)
Process 3
(384 KB)
What else is wrong though?
16 / 34
Fixed Partitioning
OS (256 KB) Process 1 (384 KB) Process 2 (384 KB) Process 3 (384 KB)What else is wrong though?
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Fixed Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(128 KB)
Process 2
(256 KB)
Process 3
(256 KB)
Some programs need less memory than others. . .
17 / 34
Fixed Partitioning
OS (256 KB) Process 1 (128 KB) Process 2 (256 KB) Process 3 (256 KB)Some programs need less memory than others. . .
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Fixed Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(128 KB)
Process 2
(256 KB)
Process 3
(256 KB)
Process 4
(512 KB)
Some programs need less memory than others. . . And some need more. . .
18 / 34
Fixed Partitioning
OS (256 KB) Process 1 (128 KB) Process 2 (256 KB) Process 3 (256 KB) Process 4 (512 KB)Some programs need less memory than others. . . And some need more. . .
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Fixed Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(128 KB)
Process 2
(256 KB)
Process 3
(256 KB)
Process 4
(512 KB)
Variable-sized partitions solve the problem
19 / 34
Dynamic Partitioning
OS (256 KB) Process 1 (128 KB) Process 2 (256 KB) Process 3 (256 KB) Process 4 (512 KB)Variable-sized partitions solve the problem
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Dynamic Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(128 KB)
Process 2
(256 KB)
Process 3
(256 KB)
Process 4
(512 KB)
Variable-sized partitions solve the problem . . . or do they? Next process needs
◮ 64KB
Where should you put it?
19 / 34
Dynamic Partitioning
OS (256 KB) Process 1 (128 KB) Process 2 (256 KB) Process 3 (256 KB) Process 4 (512 KB)Variable-sized partitions solve the problem . . . or do they? Next process needs
◮ 64KBWhere should you put it?
2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Dynamic Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 1
(128 KB)
Process 2
(256 KB)
Process 3
(256 KB)
Process 4
(512 KB)
Variable-sized partitions solve the problem . . . or do they? Next three processes need
◮ 64KB ◮ 64KB ◮ 256 KB
Or perhaps next four processes need
◮ 64KB ◮ 96 KB ◮ 96 KB ◮ 128 KB
19 / 34
Dynamic Partitioning
OS (256 KB) Process 1 (128 KB) Process 2 (256 KB) Process 3 (256 KB) Process 4 (512 KB)Variable-sized partitions solve the problem . . . or do they? Next three processes need
◮ 64KB ◮ 64KB ◮ 256 KBOr perhaps next four processes need
◮ 64KB ◮ 96 KB ◮ 96 KB ◮ 128 KB2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Dynamic Partitioning
Programs, Memory, & Address Space Filling Memory
OS
(256 KB)
Process 2
(256 KB)
Process 4
(512 KB)
Process 5
(384 KB)
Dynamic partitions solve the problem ... or do they? Next process needs
◮ 384 KB
20 / 34
Dynamic Partitioning
OS (256 KB) Process 2 (256 KB) Process 4 (512 KB) Process 5 (384 KB)Dynamic partitions solve the problem ... or do they? Next process needs
◮ 384 KB2013-05-19
CS34 Programs, Memory, & Address Space Filling Memory Dynamic Partitioning
Programs, Memory, & Address Space Selecting Space
Best fit?
◮ Choose smallest hole that is large enough
Worst fit?
◮ Choose largest hole that is large enough
First fit?
◮ Choose first hole that is large enough
Next fit?
◮ Choose first hole that is large enough, starting search after
last hole we allocated from
21 / 34
Which Hole?
Best fit?
◮ Choose smallest hole that is large enoughWorst fit?
◮ Choose largest hole that is large enoughFirst fit?
◮ Choose first hole that is large enoughNext fit?
◮ Choose first hole that is large enough, starting search afterlast hole we allocated from
2013-05-19
CS34 Programs, Memory, & Address Space Selecting Space Which Hole?
Programs, Memory, & Address Space Selecting Space
Which method is best?
8K
allocated block (14K)
Which hole? Class Exercise
Which method is best?
8KCS34 Programs, Memory, & Address Space Selecting Space Which hole?
Programs, Memory, & Address Space Selecting Space
All methods are prone to fragmentation
◮ Best fit and first fit have least fragmentation on average
How can we avoid external fragmentation?
23 / 34
External Fragmentation
All methods are prone to fragmentation
◮ Best fit and first fit have least fragmentation on averageClass Exercise
How can we avoid external fragmentation?
2013-05-19
CS34 Programs, Memory, & Address Space Selecting Space External Fragmentation
Can eliminate fragmentation by compaction
Programs, Memory, & Address Space Memory Sharing
What if two people are running the same editor?
24 / 34
Wasted Memory...?
What if two people are running the same editor?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Wasted Memory...?
Programs, Memory, & Address Space Memory Sharing
We could introduce segments—code and data:
◮ Program code is put in a program segment (read only),
shared between processes
◮ Program data is put in a data segment, unique to each
process
25 / 34
Segments
We could introduce segments—code and data:
◮ Program code is put in a program segment (read only),shared between processes
◮ Program data is put in a data segment, unique to eachprocess
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segments
Programs, Memory, & Address Space Memory Sharing
segment table CS DS
base segment limit
6702 3766 4178 1118
CS:0 address
logical memory process 1
foo EDITOR
CS:3766 DS:0 DS:1118
segment table CS DS
base segment limit
6702 3766 12164 1284
CS:0 address
logical memory
EDITOR
CS:3766 DS:0 DS:1284
process 3
xyzzy
segment table CS DS
base segment limit
6702 3766 1738 910
CS:0 address
logical memory
EDITOR
CS:3766 DS:0 DS:910
bar
process 2
physical memory
1738 4178 6702 12164 address
E D I T O R xyzzy foo bar
16384
26 / 34
Segments
segment table CS DS base segment limit 6702 3766 4178 1118 CS:0 address logical memory process 1 foo EDITOR CS:3766 DS:0 DS:1118 segment table CS DS base segment limit 6702 3766 12164 1284 CS:0 address logical memory EDITOR CS:3766 DS:0 DS:1284 process 3 xyzzy segment table CS DS base segment limit 6702 3766 1738 910 CS:0 address logical memory EDITOR CS:3766 DS:0 DS:910 bar process 2 physical memory 1738 4178 6702 12164 address EDITOR xyzzy foo bar 163842013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segments
Programs, Memory, & Address Space Memory Sharing
If two segments are a good idea, would more be even better?
27 / 34
More Segments
If two segments are a good idea, would more be even better?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing More Segments
Programs, Memory, & Address Space Memory Sharing
If two segments are a good idea, would more be even better? How about...
◮ A stack segment?
Any other segments that might be nice to have?
27 / 34
More Segments
If two segments are a good idea, would more be even better? How about...
◮ A stack segment?Class Exercise
Any other segments that might be nice to have?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing More Segments
Programs, Memory, & Address Space Memory Sharing
If two segments are a good idea, would more be even better? (The x86 has CS, DS, SS and ES)
27 / 34
More Segments
If two segments are a good idea, would more be even better? (The x86 has CS, DS, SS and ES)
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing More Segments
Programs, Memory, & Address Space Memory Sharing
If two segments are a good idea, would more be even better? How about...
◮ A stack segment? ◮ A shared-data segment? ◮ A heap segment? ◮ A segment for the C library ◮ A thread-local storage segment ◮ A bonus segment?
27 / 34
More Segments
If two segments are a good idea, would more be even better? How about...
◮ A stack segment? ◮ A shared-data segment? ◮ A heap segment? ◮ A segment for the C library ◮ A thread-local storage segment ◮ A bonus segment?2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing More Segments
Programs, Memory, & Address Space Memory Sharing
If two segments are a good idea, would more be even better? How about...
◮ A stack segment? ◮ A shared-data segment? ◮ A heap segment? ◮ A segment for the C library ◮ A thread-local storage segment ◮ A bonus segment?
The x86 has CS, DS, SS, ES, plus FS and GS.
27 / 34
More Segments
If two segments are a good idea, would more be even better? How about...
◮ A stack segment? ◮ A shared-data segment? ◮ A heap segment? ◮ A segment for the C library ◮ A thread-local storage segment ◮ A bonus segment?The x86 has CS, DS, SS, ES, plus FS and GS. Problems?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing More Segments
Confused programmers!
into Are six segments enough?
Programs, Memory, & Address Space Memory Sharing
Logical address consists of the pair <segment-number, offset>
Use 32-bit logical address
◮ High-order 8 bits are segment number ◮ Low-order 24 bits are offset within segment
256 segments, of max size 16,777,216 bytes (16MB)
28 / 34
Segmentation Architecture
Logical address consists of the pair <segment-number, offset> Example Use 32-bit logical address
◮ High-order 8 bits are segment number ◮ Low-order 24 bits are offset within segment256 segments, of max size 16,777,216 bytes (16MB)
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture
Programs, Memory, & Address Space Memory Sharing
Processor needs to map 2D user-defined addresses into 1D physical addresses. In segment table, each entry has:
◮ Base—Starting address of the segment in physical memory ◮ Limit—Length of the segment
29 / 34
Segmentation Architecture—Segment Table
Processor needs to map 2D user-defined addresses into 1D physical addresses. In segment table, each entry has:
◮ Base—Starting address of the segment in physical memory ◮ Limit—Length of the segment2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture—Segment Table
Programs, Memory, & Address Space Memory Sharing
s d l
s
b
b m
segment table physical address logical address
physical memory
+
base limit
b
< d < l
l
TRAP
What are the practical limits on the number of segments?
30 / 34
Segment Table
Processor
s d l s b b m segment table physical address logical address physical memory + base limit b < d < l l TRAPClass Exercise
What are the practical limits on the number of segments?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segment Table
Programs, Memory, & Address Space Memory Sharing
Design Issues:
◮ Relocation
◮ Dynamic ◮ By segment table
◮ Sharing
◮ Shared segments ◮ Same segment number
◮ Allocation
◮ First fit/best fit ◮ External fragmentation
Do shared segments need to have the same segment number?
◮ If so, why? ◮ If not, why? (And why
might we give them the same segment number anyway?)
31 / 34
Segmentation Architecture
Design Issues:
◮ Relocation ◮ Dynamic ◮ By segment table ◮ Sharing ◮ Shared segments ◮ Same segment number ◮ Allocation ◮ First fit/best fit ◮ External fragmentationClass Exercise
Do shared segments need to have the same segment number?
◮ If so, why? ◮ If not, why? (And whymight we give them the same segment number anyway?)
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture
Programs, Memory, & Address Space Memory Sharing
Does our segmentation scheme capture the difference between code and data segments?
◮ If not, what would we need to fix it?
What if a program wants more contiguous data space than a segment can hold? Is this a problem?
32 / 34
Segmentation Architecture Class Exercise
Does our segmentation scheme capture the difference between code and data segments?
◮ If not, what would we need to fix it?Class Exercise
What if a program wants more contiguous data space than a segment can hold? Is this a problem?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture
With each entry in segment table, associate:
segment level
Programs, Memory, & Address Space Memory Sharing
What kinds of fragmentation do we have?
◮ Internal ◮ External
What’s the cause of the fragmentation?
33 / 34
Segmentation Architecture—Fragmentation Class Exercise
What kinds of fragmentation do we have?
◮ Internal ◮ ExternalWhat’s the cause of the fragmentation?
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture—Fragmentation
Programs, Memory, & Address Space Memory Sharing
What kinds of fragmentation do we have?
◮ Internal—Not a problem ◮ External—We have a problem! (And compaction would take
too long) What’s the cause of the fragmentation?
◮ Differing segment sizes
33 / 34
Segmentation Architecture—Fragmentation Class Exercise
What kinds of fragmentation do we have?
◮ Internal—Not a problem ◮ External—We have a problem! (And compaction would taketoo long) What’s the cause of the fragmentation?
◮ Differing segment sizes2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture—Fragmentation
Programs, Memory, & Address Space Memory Sharing
What kinds of fragmentation do we have?
◮ Internal—Not a problem ◮ External—We have a problem! (And compaction would take
too long) What’s the cause of the fragmentation?
◮ Differing segment sizes
Make all segments the same size!
◮ But now we have internal fragmentation! ◮ Better make the segments small, to minimize
wastage—remember, we can cope with small segments
33 / 34
Segmentation Architecture—Fragmentation Class Exercise
What kinds of fragmentation do we have?
◮ Internal—Not a problem ◮ External—We have a problem! (And compaction would taketoo long) What’s the cause of the fragmentation?
◮ Differing segment sizesCrazy Solution !?! Make all segments the same size!
◮ But now we have internal fragmentation! ◮ Better make the segments small, to minimizewastage—remember, we can cope with small segments
2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Segmentation Architecture—Fragmentation
Programs, Memory, & Address Space Memory Sharing
Properties
◮ All segments are the same size (e.g., 4K) ◮ No need for limit registers ◮ No longer reflect program structure
34 / 34
Tiny Segments
Properties
◮ All segments are the same size (e.g., 4K) ◮ No need for limit registers ◮ No longer reflect program structure2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Paging
Programs, Memory, & Address Space Memory Sharing
Properties
◮ All pages are the same size (e.g., 4K) ◮ No need for limit registers ◮ No longer reflect program structure ◮ Physical locations for pages are called page frames
34 / 34
Paging
Properties
◮ All pages are the same size (e.g., 4K) ◮ No need for limit registers ◮ No longer reflect program structure ◮ Physical locations for pages are called page frames2013-05-19
CS34 Programs, Memory, & Address Space Memory Sharing Paging