1 / 48

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

[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, 그리고 ‘ 팀 프로젝트 ’ 의 경험이 있는 학생들의 입장에서 ,

nicole
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. [2011-2] 시스템 프로그래밍Week 1 : Course Overview 담당교수 : 최 윤 정 2011. 8.30

  2. [2011-2] • [시스템 프로그래밍] • C& Assembly • gcc in Unix • 학습 목표 • Quiz • 강의 목표 • 운영 방법 • 평가 방법 • [컴퓨터 프로그래밍2] • C • Visual Studio & gcc in Unix

  3. 10분 Quiz 1학기 Java와 C,그리고 ‘팀 프로젝트’의 경험이 있는 학생들의 입장에서, 지금쯤.. 여러분에게 “프로그래밍”이란 어떤 의미인가요? 지금까지 만들어보았던 프로그래밍의 결과물 중 가장 보람있던 것이 있다면? “시스템 프로그래밍”시간에는 무엇을 배우게 될 것 같나요? 또는 특별히 무엇에 대해 배우고 싶은가요?

  4. 자고 일어나면 맨 땅에 새로운 건물 하나가 지어지던 시절 … 1969년.. 서울에 ‘와우아파트’가 지어집니다.

  5. 산 비탈에 지어진 아파트, 그러나.. 곧 무너집니다. 원인은 … ‘부실공사’ 철근 70개 5개 처음부터 ‘지질검사’조차 하지 않았습니다. … ‘화강암석이니 단단하겠지’

  6. 1977년 .. 전북 ‘이리역’이 폭발합니다.. 1993년 .. 서해훼리호가 침몰합니다..

  7. 1994년.. 성수대교

  8. 1995년.. 삼풍백화점 … 사망자 500여명 부상자 900여명

  9. 공학자로서 • 여러분이 생각하는 • ‘부실함’과 ‘튼실함’의 차이는…? • 그 영역과 범위는……?

  10. 컴퓨터를 사용하면서.. • 불안하다고 느낀 적은? • H/W …… S/W • 학생으로서 • 사용자로서 • 개발자로서

  11. IPTV 3사의 셋탑박스들

  12. "몇 년 있으면 바닥날 석유만 믿고 있으면 안 되며 석유 이외에서 돈을 벌되 신속하고 획기적으로 벌어야 한다" "두바이에서는 실패를 제외한 모든 것이 가능하다" "미래를 바꾸려고 시도하지 않는 사람은 과거의 노예상태로 머무르게 된다“ 두바이는전속력으로 달리는 일만 남았다“ - 쉐이크 모하메드-

  13. 학습 목표 • [시스템 프로그래밍] 수업에서는 • 배경지식을 보다 깊이, 정확하게 쌓아둘 것. • 다양한 Platform의 특성에 의한 효율성과 최적화를 고려할 것. • h/w 특성, 설계 구조 • 메모리들, 처리속도, 알고리즘 외적인 부분에서의 효율성 • 주어진 문제와 개발 환경에 대한 ‘이해력’과 ‘통찰력’이 요구 • S/W 개발에 대한 적응력 배양 : 여러 가지의 버그들 , 에러들 • 이후 전공과목을 위한 기반지식으로써의 의미를 부여할 것

  14. 교재안내 • 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

  15. Carnegie Mellon Curriculum Operating Systems Compilers Embedded Systems Embedded System Eng. Databases Networks Digital Computation Architecture Network Protocols Processes Mem. Mgmt Machine Code Data Reps. Memory Model Execution Model Memory System Arithmetic System Programming Foundation of Computer SystemsUnderlying principles for hardware, software, and networking C Programming

  16. 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

  17. 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

  18. 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....

  19. 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) --> ??

  20. Carnegie Mellon Reality #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!

  21. 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);

  22. 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 compiler static 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"); }

  23. 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 improvements

  24. 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)

  25. Carnegie Mellon Memory System Performance Example void copyij(intsrc[2048][2048], intdst[2048][2048]) { inti,j; for (i = 0; i < 2048; i++) for (j = 0; j < 2048; j++) dst[i][j] = src[i][j]; } void copyji(intsrc[2048][2048], intdst[2048][2048]) { inti,j; for (j = 0; j < 2048; j++) for (i = 0; i < 2048; i++) dst[i][j] = src[i][j]; } • Hierarchical memory organization • Performance depends on access patterns • Including how step through multi-dimensional array

  26. Carnegie Mellon The Memory Mountain Intel Core i7 2.67 GHz 32 KB L1 d-cache 256 KB L2 cache 8 MB L3 cache

  27. 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

  28. 강의 운영 방법 • 수업자료실 : http://home.konkuk.ac.kr/~cris/ • 강의내용 및 게시판 : 질의응답용 • 이론의 이해도 확인 후 실습 • 이론 학습 후 필요 시 퀴즈 / 확인 실습 • 실습 실 지정좌석제 • Lectures & Lab • Concepts, important tools and skills for labs • clarification of lectures, exam coverage • Exams : mid + final + quiz

  29. 과제 형태 • 조사과제 : report • 조사내용을 정리하여 수업 전 제출합니다. • 실습 과제 1: 지시에 따라 source화일 작성 • 제한된 명령어와 연산자의 종류를 이용하여 ‘기능’을 구현함. • 조건 별 채점 • 실습 과제 2: source 파일 (주석작성) + 실행 파일 • source 화면 + 결과화면 출력하여 제출(축소 후 1~2장으로) • source화일와실행화일은 수업게시판에 비밀글로upload. • 개인별 수행을 원칙으로 함.

  30. 평가 방법 및 정책 • 실습 과제 1 : 개별 제출 • 과제 확인 시간 금요일 2시~5시 • 실습 과제 2: 자동평가 시스템 • 팀으로 수행하여 제출한 경우에도 반드시 개별적으로 tool과 code에 대한 모든 동작상태를 설명해야 합니다. • 과제 제출 마감 후 : -2점 / 1일 • 중간 및 기말고사 후 필요시 재시험 • 반영 비율 • 중간고사: 30%, 기말고사: 30% • 퀴즈 및 과제물 : 30% • 출석 및 수업참여도 : 10%

  31. 수업 상담 및 help Office hours: 1:1 상담은 미리 약속하세요 수업 조교 지원

  32. Topics :

  33. 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

  34. 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.

  35. Carnegie Mellon Performance • Topics • Co-optimization (control and data), measuring time on a computer • Includes aspects of architecture, compilers, and OS

  36. 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

  37. 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

  38. 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.

More Related