Download hello

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

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