• 검색 결과가 없습니다.

7154.pdf

N/A
N/A
Protected

Academic year: 2024

Share "7154.pdf"

Copied!
20
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Computer SW and HW

(2)

Information in Computer Systems

 Every Info. is a Sequence of bits.

– Source Program: Sequence of bits (Text file)

#include <stdio.h>

int main() {

printf(hello, world\n);

}

# i n c l u d e <sp> < s t d i 35 105 110 99 108 117 100 101 32 60 115 116 100 105

– Executable Program: Sequence of bits (Binary file)

.&##A.+?@@^

(3)

3

Source Program vs. Executable Program

 unix> gcc -o hello hello.c

– compiler (gcc) translates the source program to the executable program

 Compiling phases

Pre- processor

(cpp)

hello.i Compiler (cc1)

hello.s Assembler (as)

hello.o Linker (ld)

hello hello.c

Source program

(text)

Modified source program

(text)

Assembly program

(text)

Relocatable object programs

(binary)

Executable object program

(binary) printf.o

– Preprocessing phase: Modify the original C program according to directives (e.g., #include)

– Compilation phase: translate to assembly-language program – Assembly phase: translate to relocatable object program

– Linking phase: merge with other pre-compile object file and

result in the executable program

(4)

How the executable program runs on a computer?

 unix> ./hello

 hello, world

 unix>

 To understand what happens here, let ’ s take a look at

the hardware organization of a computer

(5)

5

Main memory I/O

bridge Bus interface

ALU Register file

CPU

System bus Memory bus

Disk controller Graphics

adapter USB

controller

Mouse Keyboard Display

Disk

I/O bus Expansion slots for other devices such as network adapters

hello executable stored on disk PC

Hardware Organization

(6)

Hardware Organization

 Buses

– a collection of electrical conduits

– number of conduits = bus width = number of bits = word

– Intel Pentium (32bits), Sun SPARCS (64bits), embedded controllers (8bits or 16bits)

 I/O Devices

– system’s connection to the external world

– Input (Keyboard, Mouse), Output (display), Storage of data and program (disk)

– Each I/O device is connected to the I/O bus by either a controller or an adapter

controller: chip set in the device itself or on the motherboard

adapter: card that plugs into a slot of the motherboard

 Main Memory

– a temporary storage device that holds both a program and the data it manipulates while the program is executing the program

– Physically, a collection of DRAM chips – Logically, a linear array of bytes

(7)

7

Hardware Organization

 Processor

– the engine that interprets and executes instructions stored in main memory

– A word size register called the Program Counter always points a machine instruction to be executed next

– After power-on, the processor repeats

reads the instruction from the memory pointed by PC

interprets the bits in the instruction

perform some simple operation (load, store, calculate, I/O read, I/O write, Jump) dictated by the instruction

update the PC to point the next instruction

add02 sub01 Memory

Bus interface

ALU Register file

CPU

PC

mul00

(8)

Executing Instructions

 Repeat fetch-execute cycles

– Program Counter (PC) always points the next instruction addr.

– 인출-실행 명령 주기 fetch-execution instruction cycle 1. 인출 fetch: 주소(PC)에 의거하여 명령어 인출

2. 실행 execute: 가져온 명령어가 요구하는 일을 수행

① PC가 가리키는 곳으로부터 명령을 인출

③ 명령의 해석(디코딩) 및 실제주소의 계산

② PC를 한 명령만큼 앞으로 (PC ← PC + n)

④ 명령에 명시된 피연산자를 인출

⑤ 명령의 실행

⑥ 계산결과의 저장

(9)

9

Running the hello program

Main memory I/O

bridge Bus interface

ALU Register file

CPU

System bus Memory bus

Disk controller Graphics

adapter USB

controller

MouseKeyboard Display

Disk

I/O bus Expansion slots for other devices such as network adapters PC

"hello"

User types

"hello"

Shell program is executing its instructions, reading characters (“./hello”) from keyboard into a register and storing them in memory

(10)

Running the hello program

After enter, the shell program load the executable “hello” file by

executing a sequence of instructions that copies the code and data in the hello object file from disk to memory (using DMA)

Main memory I/O

bridge Bus interface

ALU Register file

CPU

System bus Memory bus

Disk controller Graphics

adapter USB

controller

MouseKeyboard Display

I/O bus Expansion slots for other devices such as network adapters

hello executable PC

hello code

"hello,world\n"

(11)

11

Running the hello program

Then, the processor begins executing the instructions in the hello

program that copy the bytes in the “hello, world\n” string from memory to the register file, and from there to the display device

Main memory I/O

bridge Bus interface

ALU Register file

CPU

System bus Memory bus

Disk controller Graphics

adapter USB

controller

Mouse Keyboard Display

Disk

I/O bus Expansion slots for other devices such as network adapters

hello executable stored on disk PC

hello code

"hello,world\n"

"hello,world\n"

(12)

Caches Matter

 Program execution

– moving information (code and data) from one place to another

– Much of this copying is overhead that slow down the “real work” of the program

– How to make these copy operations run as fast as possible?

 Physical laws

– larger storage devices are slower than smaller storage devices

– faster devices are more expensive to build than their slower counter part

– e.g., disk drive 100 times larger than main memory (10,000,000 times longer read time than memory)

- smaller faster storage devices (caches)

Main memory Memory

bridge Bus interface

L2 cache (SRAM)

ALU Register file

CPU chip

Cache bus System bus Memory bus

L1 cache (SRAM)

(13)

13

Generalizing the Cache Idea: Memory Hierarchy

 storage at one level serves as a cache for storage at the next lower level.

Registers On-chip L1 cache (SRAM)

Main memory (DRAM)

Local secondary storage (local disks)

Larger, slower,

and cheaper (per byte)

storage devices

Remote secondary storage

(distributed file systems, Web servers)

Local disks hold files retrieved from disks on remote network servers.

Off-chip L2 cache (SRAM)

L1 cache holds cache lines retrieved from the L2 cache.

CPU registers hold words retrieved from cache memory.

L2 cache holds cache lines retrieved from memory.

L0:

L1:

L2:

L3:

L4:

L5:

Smaller, faster,

and costlier (per byte)

storage devices

(14)

Application Program vs. HW

 Think about the scenario where application program directly control all HW resources

 Why we need pre-build system software layer (like operating system)?

application SW System Software

(e.g., Operating System)

HW

(15)

15

Operating System

 Note! our “ hello ” example does not directly access display or disk directly.

 Rather, it relies on the services provided by the operating system.

 OS ’ s two primary purposes

– to protect the hardware from misuse by runaway applications – to provide applications with simple and uniform mechanisms

for manipulating complicated and often widely different low- level hardware devices

Application programs

Processor Main memory I/O devices Operating system

Software Hardware

(16)

Abstractions provided by an Operating System

 Files: abstractions for I/O devices

 Virtual Memory: abstraction for both the main memory and disk I/O devices

 Processes: abstractions for the processor, main memory and I/O devices

Processor Main memory I/O devices Processes

Files Virtual memory

(17)

17

Processes

 A process is the operating system ’ s abstraction for a running program

 The OS provides the illusion that the program is the only one running on the system

 Multiple processes can run concurrently on the same system, but each process appears to have exclusive use of the hardware

 To give this illusion, the OS saves the context (PC, register files, memory contents) and switches among contexts of different

processes - context switches

shell process

hello process

Application code Time

Context switch

Context switch OS code

Application code OS code

Application code

(18)

Virtual Memory

Virtual memory is an

abstraction that provides each process with the illusion that it has

exclusive use of main memory.

Each process has the same uniform view of memory, virtual address space.

The basic idea is to store the contents of a

process’s virtual memory on disk and then load subset of the contents into the main memory as needed using the main memory as a cache for the disk

Kernel virtual memory

Memory mapped region for shared libraries

Run-time heap

(created at runtime by malloc) User stack

(created at runtime)

Unused

Memory invisible to user code

0xc0000000

0x08048000 0x40000000

Read/write data Read-only code and data

Loaded from the

hello

executable file

printf() function

0xffffffff

(19)

19

Networked Computer System

The network can be viewed as just another I/O device (from the individual system’s viewpoint) by the support of OS

Main memory I/O

bridge Bus interface

ALU Register file

CPU chip

System bus Memory bus

Disk controller Graphics

adapter USB

controller

Mouse Keyboard Monitor

Disk I/O bus

Expansion slots

Network adapter

Network PC

Local telnet client

Remote telnet server 2. Client sends "hello"

string to telnet server 3. Server sends "hello"

string to the shell, which runs the hello program,

and sends the output to the telnet server 4. Telnet server sends

"hello, world\n" string to client

5. Client prints

"hello, world\n"

string on display 1. User types

"hello" at the keyboard

(20)

Summary

Information in Computer Systems (bits)

Transform the source code to the executable. What does it mean?

What happens when we run a program?

Understanding the hardware organization

Understanding the information flow along the HW resources

Performance consideration - memory hierarchy

Marriage of application program and hardware - intermediate layer (system software)

Operating system as a peace maker

processes virtual memory files

network

참조

관련 문서

Since GC-tune finds the optimal memory size by executing the target program with all the different possible GC options, the GC-tuning time takes too long.. This

The embedded simulation program is executed in TCU processor along with the TCU firmware and it provides TCU firmware with not only the speed information those

15번 다음을 듣고, Senior Learning Program 에 관한 내용과 일치하지 않는 것을 고르시오.. W: Hello, I’m Emily White, the director of the

safety control, leaders' experience and knowledge, leaders' kindness, participation convenience, Information sign, smooth running of the schedule, program contents,

Third, the hospital has built systematic RTE-based environment as an application program in which the nU System is linked to Business Processor Renovation (BPR)

 Echo server and echo client are the socket programming equivalence of Hello World program found in typical

With the developed program, the characteristics of geometric contact, including the contact during steady state running, were analyzed and discussed for

명 령어와 컴파일러 설계 결과를 검증하기 위하여 크로노스그룹에서 제안하는 Conformance Test를 수행하였다.. Variable-length instructions are proposed to