introduction to system programming coursecsl.skku.edu/uploads/swe2001s17/1-introduction.pdf ·...

22
1 SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected]) Introduction to System Programming Course 2017 Spring Euiseong Seo ([email protected])

Upload: others

Post on 06-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

1SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Introduction toSystem Programming Course

2017 SpringEuiseong Seo

([email protected])

Page 2: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

2SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Overview§ What this course is about§ Who teaches this course§ Why you have to take this course§ What you will learn in this course§ What you will earn in this course§ How to succeed in this course

Page 3: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

3SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

What This Course is About§ System Programming

• Information representation• Assembly language• Processor architecture• Compilers, linkers, and loaders

Page 4: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

4SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Administrative Information§ Course Code

• SWE 2001

§ Class Hour• Monday: 16:30 ~ 17:45• Wednesday: 15:00 ~ 16:15

§ Lecture Room• #26312 (located on 3F of Engineering Bldg. II)

Page 5: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

5SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Textbook§ Computer Systems:

A Programmer’s Perspective (3rd Ed.)• Randal E. Bryant and David R. O’Hallaron• 2016 Prentice-Hall• Authors’ site: http://csapp.cs.cmu.edu

Page 6: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

6SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Course Components§ Lectures

• Concepts• Backgrounds

§ Projects• Mostly on assembly programming• Design, implementation, measurement and

optimization

Page 7: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

7SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Course Web Page§ http://csl.skku.edu/SWE2001S17§ Check the web site regularly§ Class material, project information and

other useful things will be posted

Page 8: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

8SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Grading§ Proportion of Activities

• Participation 10%• Projects 30%• Midterm 30%• Final 30%

§ If you miss any exam, you will fail§ No late attendance is allowed§ Up to four absences will be tolerated

Page 9: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

9SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Project§ You will work on each project alone§ The submission status will be posted on

the course web page§ Only the assignments submitted before

the deadline will receive credit

Page 10: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

10SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Ethical Code§ No academic misconduct will be tolerated

• Zero-tolerance policy• One who is found guilty will be kicked out of

my class immediately

Page 11: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

11SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Lecturer§ Euiseong Seo

• Associate professor, Software Dept.• E-Mail: euiseong (at) skku.edu• Office: #85564• Phone: (031) 299-4953

Page 12: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

12SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Why You Have to Take This§ Abstraction is Good, But Don’t Forget Reality

• Most CSE courses emphasize abstraction– Abstract data types– Asymptotic analysis

• These abstractions have limitation– In performance optimization– In detection and elimination of bugs

Page 13: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

13SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Great Reality§ Ints are not Integers, Floats are not Reals

• Example 1: Is x^2 >= 0?– Float’s: Yes!– Int’s:

» 40000 * 40000 = 1600000000» 50000 * 50000 = ??

• Example 2: Is ( x + y ) + z = x + (y + z)?– Unsigned & signed Int’s: Yes!– Float’s:

» (1e20 + -1e20) + 3.14 = 3.14» 1e20 + (-1e20 + 3.14) = ??

Page 14: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

14SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Great Reality§ Does not generate random values

• Arithmetic operations have important mathematical properties

§ Cannot assume all “usual” mathematical properties• Due to finiteness of representations• Integer operations satisfy “ring” properties

– Commutativity, associativity, distributivity• Floating point operations satisfy “ordering” properties

– Monotonicity, values of signs

§ Observation• Need to understand which abstractions apply in which

contexts• Important issues for compiler writers and serious

application programmers

Page 15: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

15SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Great Reality§ When you measure the required time to

execute a part of your code, what can you do?• Measuring time in clock cycle accuracy is necessary

§ Time Stamp Counter• A special 64-bit register in Intel-compatible machines• Incremented every clock cycle• Read with rdtsc instruction• Why couldn’t it be possible with a C-function?

Page 16: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

16SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Great Reality§ 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

Page 17: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

17SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Great Realitytypedef struct {int a[2];double d;

} struct_t;

double fun(int i) {volatile struct_t s;s.d = 3.14;s.a[i] = 1073741824; /* Possibly out of bounds */return s.d;

}

fun(0) ➙ 3.14fun(1) ➙ 3.14fun(2) ➙ 3.1399998664856fun(3) ➙ 2.00000061035156fun(4) ➙ 3.14fun(6) ➙ Segmentationfault

Page 18: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

18SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

What You Will Learn§ A little bit of computer organization§ A little bit of processor internals§ Assembly language§ Code optimization techniques§ A little bit of system software

• Compiler, linker, loader, OSs and so on

Page 19: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

19SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

What You Will Learn%QWTUG 1WVNKPG ��%QWTUG 1WVNKPG ��%QWTUG�1WVNKPG���%QWTUG�1WVNKPG���� %QORWVGT�U[UVGOU�KPVGTPCNUR [

Software Application

Operating�Systems

I/O Devices

Architecture

CPU MemI/O�Devices

Hardware

5CSE2003: System Programming | Spring 2010| Jin-Soo Kim ([email protected])

Page 20: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

20SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

%QWTUG 1WVNKPG ��%QWTUG 1WVNKPG ��%QWTUG�1WVNKPG���%QWTUG�1WVNKPG���� .GXGNU�QH�CDUVTCEVKQP

Data�structures�&�algorithms

Application�programs

Operating�System

Programming�languages�&�compilers

g

Architecture

Microarchitecture

Hardware�Description�Languages

Digital�logic

VLSI�layout

Processing,�Fabrication

6CSE2003: System Programming | Spring 2010| Jin-Soo Kim ([email protected])

Chemistry,�Physics

Page 21: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

21SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

What You Will Earn§ You will become more effective programmers

• Able to find and eliminate bugs efficiently• Able to understand and tune for program performan

ce

§ You will be prepared for later “systems” classes in CSE• Compilers, Operating Systems, Computer Architecture

, Embedded Systems and etc.

Page 22: Introduction to System Programming Coursecsl.skku.edu/uploads/SWE2001S17/1-introduction.pdf · 2017-03-06 · •Compiler, linker, loader, OSs and so on. SWE2001: System Program |

22SWE2001: System Program | Spring 2017 | Euiseong Seo ([email protected])

Keys to Success§ Think with your butt, not with your brain§ Invest as many hours as possible§ There’s no royal road to become a hacker