130 likes | 157 Vues
Learn about the phases of the compilation process - Pre-processor, Compiler, Assembler, Linker - and the journey from source code to executable program. Discover the roles of CPU, Memory, I/O, and more. Dive into storage devices, registers, caches, and system buses.
E N D
printf.o Pre- processor (cpp) Compiler (cc1) Assembler (as) Linker (ld) hello.c hello.i hello.s hello.o hello Source program (text) Assembly program (text) Modified source program (text) Relocatable object programs (binary) Executable object program (binary)
CPU Register file ALU PC System bus Memory bus Main memory Bus interface I/O bridge I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk hello executable stored on disk
CPU Register file ALU PC System bus Memory bus Main memory "hello" Bus interface I/O bridge I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk User types "hello"
CPU Register file ALU PC System bus Memory bus Main memory "hello,world\n" Bus interface I/O bridge hello code I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk hello executable stored on disk
CPU Register file ALU PC System bus Memory bus Main memory "hello,world\n" Bus interface I/O bridge hello code I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk hello executable stored on disk "hello,world\n"
CPU chip Register file L1 cache (SRAM) ALU Cache bus System bus Memory bus Main memory (DRAM) L2 cache (SRAM) Bus interface Memory bridge
L1 cache holds cache lines retrieved from the L2 cache. L2 cache holds cache lines retrieved from memory. Main memory holds disk blocks retrieved from local disks. Local disks hold files retrieved from disks on remote network servers. L0: 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:
Application programs Software Operating system Processor Main memory I/O devices Hardware
Processes Virtual memory Files Processor Main memory I/O devices
shell process hello process Time Application code Context switch OS code Application code Context switch OS code Application code
Memory 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
CPU chip Register file ALU PC System bus Memory bus Main memory Bus interface I/O bridge Expansion slots I/O bus USB controller Network adapter Graphics adapter Disk controller Mouse Keyboard Monitor Disk Network
2. Client sends "hello" string to telnet server 1. User types "hello" at the keyboard 3. Server sends "hello" string to the shell, which runs the hello program, and sends the output to the telnet server Local telnet client Remote telnet server 4. Telnet server sends "hello, world\n" string to client 5. Client prints "hello, world\n" string on display