48
[2011-2] 시시시 시시시시시 Week 1 : Course Overview 담담담담 : 담 담 담 2011. 8.30 1

[2011-2] 시스템 프로그래밍 Week 1 : Course Overview

  • Upload
    nicole

  • View
    122

  • Download
    3

Embed Size (px)

DESCRIPTION

[2011-2] 시스템 프로그래밍 Week 1 : Course Overview. 담당교수 : 최 윤 정 2011. 8.30. [2011-2]. [ 시스템 프로그래밍 ] C & Assembly gcc in Unix. 학습 목표 Quiz 강의 목표 운영 방법 평가 방법. [ 컴퓨터 프로그래밍 2] C Visual Studio & gcc in Unix. 10 분 Quiz. 1 학기 Java 와 C, 그리고 ‘ 팀 프로젝트 ’ 의 경험이 있는 학생들의 입장에서 , - PowerPoint PPT Presentation

Citation preview

Page 1: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

[2011-2] 시스템 프로그래밍

Week 1 : Course Overview

담당교수 : 최 윤 정

2011. 8.30

1

Page 2: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

[컴퓨터 프로그래밍2] C Visual Studio & gcc in Unix

[ 시스템 프로그래밍 ] C & Assembly gcc in Unix

[2011-2]

2

학습 목표

Quiz 강의 목표

운영 방법

평가 방법

Page 3: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

10 분 Quiz1 학기 Java 와 C, 그리고 ‘팀 프로젝트’의 경험이 있는 학생들의 입장에서 ,

1. 지금쯤 .. 여러분에게 “프로그래밍”이란 어떤 의미인가요 ?

2. 지금까지 만들어보았던 프로그래밍의 결과물 중 가장 보람있던 것이 있다면 ?

3. “ 시스템 프로그래밍” 시간에는 무엇을 배우게 될 것 같나요 ? 또는

특별히 무엇에 대해 배우고 싶은가요 ?

3

Page 4: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

4

자고 일어나면맨 땅에새로운건물 하나가지어지던 시절 …

1969 년 ..

서울에 ‘ 와우아파트’가 지어집니다 .

Page 5: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

5

산 비탈에 지어진아파트 , 그러나 ..

곧 무너집니다 .

원인은 …

‘ 부실공사’

철근 70 개 5개

처음부터‘ 지질검사’조차

하지 않았습니다 .

‘ 화강암석이니 단단하겠지’

Page 6: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

6

1977 년 ..

전북 ‘이리역’이 폭발합니다 ..

1993 년 ..

서해훼리호가 침몰합니다 ..

Page 7: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

7

1994 년 ..

성수대교

Page 8: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

8

1995 년 ..

삼풍백화점

사망자 500 여명부상자 900 여명

Page 9: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

9

공학자로서 여러분이 생각하는

‘ 부실함’과 ‘튼실함’의 차이는… ?

그 영역과 범위는…… ?

Page 10: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

10

컴퓨터를 사용하면서 ..

불안하다고 느낀 적은 ?

H/W …… S/W

학생으로서

사용자로서

개발자로서

Page 11: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

11

Page 12: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

12

IPTV 3 사의 셋탑박스들

Page 13: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

13

Page 14: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

14

Page 15: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

15

Page 16: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

16

Page 17: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

17

Page 18: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

18

Page 19: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

19

" 몇 년 있으면 바닥날 석유만 믿고 있으면 안 되며 석유 이외에서 돈을 벌되 신속하고 획기적으로 벌어야 한다 "

" 두바이에서는 실패를 제외한 모든 것이 가능하다 "

" 미래를 바꾸려고 시도하지 않는 사람은 과거의 노예상태로 머무르게 된다“

두바이는 전속력으로 달리는 일만 남았다“

- 쉐이크 모하메드 -

Page 20: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

학습 목표

[ 시스템 프로그래밍 ] 수업에서는

배경지식을 보다 깊이 , 정확하게 쌓아둘 것 . 다양한 Platform 의 특성에 의한 효율성과 최적화를 고려할 것 .

h/w 특성 , 설계 구조

메모리들 , 처리속도 , 알고리즘 외적인 부분에서의 효율성

주어진 문제와 개발 환경에 대한 ‘이해력’과 ‘통찰력’이 요구

S/W 개발에 대한 적응력 배양 : 여러 가지의 버그들 , 에러들

이후 전공과목을 위한 기반지식으로써의 의미를 부여할 것

20

Page 21: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Randal E. Bryant and David R. O’Hallaron, “Computer Systems: A Programmer’s Perspective, Second Edition”

(CS:APP2e), Prentice Hall, 2011

Brian Kernighan and Dennis Ritchie, “The C Programming Language, Second Edition”, Prentice Hall, 1988

교재 안내

21

Page 22: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Curriculum

OperatingSystems Compilers

ProcessesMem. Mgmt

Networks

NetworkProtocols

Architecture EmbeddedSystems

C Programming

Databases

Data Reps.Memory Model

DigitalComputation

MachineCode Arithmetic

EmbeddedSystem Eng.

Foundation of Computer SystemsUnderlying principles for hardware, software, and networking

Execution ModelMemory System

System Programming

22

Page 23: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Course Perspective

Most Systems Courses are Builder-Centric Computer Architecture

Design pipelined processor Operating Systems

Implement large portions of operating system Compilers

Write compiler for simple language Networking

Implement and simulate network protocols

23

Page 24: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Course Perspective (Cont.)

Our Course is Programmer-Centric Purpose is to show how by knowing more about the

underlying system, one can be more effective as a programmer

Enable you to Write programs that are more reliable and efficient Incorporate features that require hooks into OS

E.g., concurrency, signal handlers

24

Page 25: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Abstraction vs. Reality Previous courses emphasize abstraction.

Abstraction Is Good But Don’t Forget Reality! Need to understand details of underlying implementations

Useful outcomes Become more effective programmers

Able to find and eliminate bugs efficiently Able to understand and tune for program performance

Prepare for later “systems” classes in CS & ECE Compilers, Operating Systems, Networks, Computer Architecture,

Embedded Systems....

25

Page 26: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Reality #1

Ints are not Integers, Floats are not Reals Is x2 ≥ 0 ?

40000 * 40000 = 1600000000 50000 * 50000 = ??

Is (x + y) + z = x + (y + z)? Unsigned & Signed Int’s: Yes! Float’s:

(1e20 + -1e20) + 3.14 --> 3.14 1e20 + (-1e20 + 3.14) --> ??

26

Page 27: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie MellonReality #2 : You’ve Got to Know

Assembly

Understanding assembly is key to machine-level execution model Behavior of programs in presence of bugs

High-level language models break down Tuning program performance

Understand optimizations done / not done by the compiler Understanding sources of program inefficiency

Implementing system software Compiler has machine code as target Operating systems must manage process state

Creating / fighting malware : x86 assembly is the language of choice! 27

Page 28: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Assembly Code Example Read-Time Stamp Counter(rdsc)

Special 64-bit register in Intel-compatible machines Incremented every clock cycle Read with rdtsc instruction

Application Measure time (in clock cycles) required by procedure

double t;start_counter();P();t = get_counter();printf("P required %f clock cycles\n", t);

28

Page 29: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Code to Read Counter Write small amount of assembly code using GCC’s asm

facility Inserts assembly code into machine code generated by

compilerstatic unsigned cyc_hi = 0;static unsigned cyc_lo = 0;

/* Set *hi and *lo to the high and low order bits of the cycle counter. */void access_counter(unsigned *hi, unsigned *lo){ asm("rdtsc; movl %%edx,%0; movl %%eax,%1"

: "=r" (*hi), "=r" (*lo) :: "%edx", "%eax");

}

29

Page 30: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Reality #3: Memory Matters Random Access Memory Is an Unphysical

Abstraction Memory is not unbounded

It must be allocated and managed Many applications are memory dominated

Memory referencing bugs especially pernicious Effects are distant in both time and space

Memory performance is not uniform Cache and virtual memory effects can greatly affect program

performance Adapting program to characteristics of memory system can lead to

major speed improvements30

Page 31: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Memory Referencing Errors C and C++ do not provide any memory protection

Out of bounds array references Invalid pointer values Abuses of malloc/free

Can lead to nasty bugs Whether or not bug has any effect depends on system and compiler Action at a distance

Corrupted object logically unrelated to one being accessed Effect of bug may be first observed long after it is generated

How can I deal with this? Program in Java, Ruby or ML Understand what possible interactions may occur Use or develop tools to detect referencing errors (e.g. Valgrind)

31

Page 32: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie MellonMemory System Performance

Example

Hierarchical memory organization Performance depends on access patterns

Including how step through multi-dimensional array

void copyji(int src[2048][2048], int dst[2048][2048]){ int i,j; for (j = 0; j < 2048; j++) for (i = 0; i < 2048; i++) dst[i][j] = src[i][j];}

void copyij(int src[2048][2048], int dst[2048][2048]){ int i,j; for (i = 0; i < 2048; i++) for (j = 0; j < 2048; j++) dst[i][j] = src[i][j];}

32

Page 33: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

The Memory Mountains1 s2 s3 s4 s5 s6 s7 s8 s9

s10

s11

s12

s13

s14

s15

s16

s32

s64

0

1000

2000

3000

4000

5000

6000

7000

64M 16

M 4M

1M

256K 64

K 16K 4K

Stride (x8 bytes)

Rea

d th

roug

hput

(MB

/s)

Size (bytes)

L1

L2

Mem

L3

copyij

copyji

Intel Core i72.67 GHz32 KB L1 d-cache256 KB L2 cache8 MB L3 cache

33

Page 34: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Reality #4

Computers do more than execute programs

They need to get data in and out I/O system critical to program reliability and performance

They communicate with each other over networks Many system-level issues arise in presence of network

Concurrent operations by autonomous processes Coping with unreliable media Cross platform compatibility Complex performance issues

34

Page 35: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

강의 운영 방법

수업자료실 : http://home.konkuk.ac.kr/~cris/ 강의 내용 및 게시판 : 질의응답용

이론의 이해도 확인 후 실습 이론 학습 후 필요 시 퀴즈 / 확인 실습

실습 실 지정좌석제

Lectures & Lab Concepts, important tools and skills for labs clarification of lectures, exam coverage

Exams : mid + final + quiz

35

Page 36: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

과제 형태

조사 과제 : report 조사내용을 정리하여 수업 전 제출합니다 .

실습 과제 1 : 지시에 따라 source 화일 작성

제한된 명령어와 연산자의 종류를 이용하여 ‘기능’을 구현함 . 조건 별 채점

실습 과제 2 : source 파일 ( 주석작성 ) + 실행 파일

source 화면 + 결과화면 출력하여 제출 ( 축소 후 1~2 장으로 ) source 화일와 실행화일은 수업게시판에 비밀글로 upload.

개인별 수행을 원칙으로 함 .

36

Page 37: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

평가 방법 및 정책

실습 과제 1 : 개별 제출 과제 확인 시간 금요일 2 시 ~5 시

실습 과제 2: 자동 평가 시스템 팀으로 수행하여 제출한 경우에도

반드시 개별적으로 tool 과 code 에 대한 모든 동작상태를 설명해야 합니다 .

과제 제출 마감 후 : -2 점 / 1 일

중간 및 기말고사 후 필요시 재시험

반영 비율

중간고사 : 30%, 기말고사 : 30% 퀴즈 및 과제물 : 30% 출석 및 수업참여도 : 10%

37

Page 38: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

수업 상담 및 help Office hours:

1:1 상담은 미리 약속하세요

수업 조교 지원

38

Page 39: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Topics :

39

Page 40: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Programs and Data

Topics Bits operations, arithmetic, assembly language

programs Representation of C control and data structures Includes aspects of architecture and compilers

Assignments L1 (datalab): Manipulating bits L2 (bomblab): Defusing a binary bomb L3 (buflab): Hacking a buffer bomb 40

Page 41: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

The Memory Hierarchy

Topics Memory technology, memory hierarchy, caches, disks,

locality Includes aspects of architecture and OS

Assignments L4 (cachelab): Building a cache simulator and optimizing

for locality. Learn how to exploit locality in your programs.

41

Page 42: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Performance

Topics Co-optimization (control and data), measuring time on a

computer Includes aspects of architecture, compilers, and OS

42

Page 43: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Exceptional Control Flow Topics Hardware exceptions, processes, process control, Unix

signals, nonlocal jumps Includes aspects of compilers, OS, and architecture

Assignments L5 (proclab): Writing puzzles using processes and

signals. A first introduction to concurrency

43

Page 44: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Virtual Memory

Topics Virtual memory, address translation, dynamic storage

allocation Includes aspects of architecture and OS

Assignments L6 (malloclab): Writing your own malloc package

Get a real feel for systems programming

44

Page 45: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

Carnegie Mellon

Networking, and Concurrency

Topics High level and low-level I/O, network programming Internet services, Web servers concurrency, concurrent server design, threads I/O multiplexing with select Includes aspects of networking, OS, and architecture

Assignments L7 (proxylab): Writing your own Web proxy

Learn network programming and more about concurrency and synchronization.

45

Page 46: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

46

Page 47: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

47

Page 48: [2011-2]  시스템 프로그래밍 Week 1 :  Course Overview

48