Title: Building and running programs
1printf.o
Pre- processor (cpp)
Compiler (cc1)
Assembler (as)
Linker (ld)
hello.i
hello.s
hello.o
hello
hello.c
Source program (text)
Assembly program (text)
Modified source program (text)
Relocatable object programs (binary)
Executable object program (binary)
2CPU
Register file
ALU
PC
System bus
Memory bus
Main memory
I/O bridge
Bus interface
I/O bus
Expansion slots for other devices such as network
adapters
USB controller
Disk controller
Graphics adapter
Mouse
Keyboard
Display
Disk
hello executable stored on disk
3CPU
Register file
ALU
PC
System bus
Memory bus
Main memory
"hello"
I/O bridge
Bus interface
I/O bus
Expansion slots for other devices such as network
adapters
USB controller
Disk controller
Graphics adapter
Mouse
Keyboard
Display
Disk
User types "hello"
4CPU
Register file
ALU
PC
System bus
Memory bus
Main memory
"hello,world\n"
I/O bridge
Bus interface
hello code
I/O bus
Expansion slots for other devices such as network
adapters
USB controller
Disk controller
Graphics adapter
Mouse
Keyboard
Display
Disk
hello executable stored on disk
5CPU
Register file
ALU
PC
System bus
Memory bus
Main memory
"hello,world\n"
I/O bridge
Bus interface
hello code
I/O bus
Expansion slots for other devices such as network
adapters
USB controller
Disk controller
Graphics adapter
Mouse
Keyboard
Display
Disk
hello executable stored on disk
"hello,world\n"
6CPU chip
Register file
L1 cache (SRAM)
ALU
Cache bus
System bus
Memory bus
Main memory (DRAM)
Memory bridge
Bus interface
L2 cache (SRAM)
7L0
Smaller, faster, and costlier (per byte) storage
devices
Registers
CPU registers hold words retrieved from cache
memory.
On-chip L1 cache (SRAM)
L1
Off-chip L2 cache (SRAM)
L2
Main memory (DRAM)
L3
Larger, slower, and cheaper (per
byte) storage devices
Local secondary storage (local disks)
L4
Remote secondary storage (distributed file
systems, Web servers)
L5
8Application programs
Software
Operating system
Processor
Main memory
I/O devices
Hardware
9Processes
Virtual memory
Files
Processor
Main memory
I/O devices
10shell process
hello process
Time
Application code
Context switch
OS code
Application code
Context switch
OS code
Application code
11Memory invisible to user code
0xffffffff
Kernel virtual memory
0xc0000000
User stack (created at runtime)
Memory mapped region for shared libraries
printf() function
0x40000000
Run-time heap (created at runtime by malloc)
Read/write data
Loaded from the hello executable file
Read-only code and data
0x08048000
Unused
0
12CPU chip
Register file
ALU
PC
System bus
Memory bus
Main memory
I/O bridge
Bus interface
Expansion slots
I/O bus
USB controller
Network adapter
Disk controller
Graphics adapter
Mouse
Keyboard
Monitor
Disk
Network
13(No Transcript)