Course Overview - TAMU Computer Science People...

21
1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, ThirdEdition Course Overview CSCE 312 Instructor: Daniel A. Jiménez

Transcript of Course Overview - TAMU Computer Science People...

Page 1: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

1BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

CourseOverview

CSCE312

Instructor:DanielA.Jiménez

Page 2: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

2BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

Overview

¢ Coursetheme¢ Fiverealities¢ HowthecoursefitsintotheCS/ECEcurriculum¢ Academicintegrity

Page 3: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

3BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

CourseTheme:AbstractionIsGoodButDon’tForgetReality¢ MostCSandCEcoursesemphasizeabstraction§ Abstractdatatypes§ Asymptoticanalysis

¢ Theseabstractionshavelimits§ Especiallyinthepresence ofbugs§ Needtounderstand detailsofunderlyingimplementations

¢ Usefuloutcomesfromtaking312§ Becomemoreeffective programmers

§ Abletofindandeliminatebugsefficiently§ Abletounderstand andtuneforprogramperformance

§ Prepare forlater“systems”classes inCS&ECE§ Compilers, OperatingSystems,Networks,Computer Architecture,Embedded Systems,StorageSystems,etc.

Page 4: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

4BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GreatReality#1:Ints arenotIntegers,FloatsarenotReals

¢ Example1:Isx2 ≥0?

§ Float’s:Yes!

§ Int’s:§ 40000*40000➙ 1600000000§ 50000*50000➙ ??

¢ Example2:Is(x +y)+z =x +(y +z)?§ Unsigned&SignedInt’s:Yes!§ Float’s:

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

Source:xkcd.com/571

Page 5: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

5BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

ComputerArithmetic

¢ Doesnotgeneraterandomvalues§ Arithmeticoperations have importantmathematical properties

¢ Cannotassumeall“usual”mathematicalproperties§ Duetofiniteness ofrepresentations§ Integer operationssatisfy“ring”properties

§ Commutativity,associativity, distributivity§ Floatingpointoperations satisfy“ordering”properties

§ Monotonicity,valuesofsigns

¢ Observation§ Needtounderstand whichabstractions applyinwhichcontexts§ Important issues forcompilerwritersandseriousapplicationprogrammers

Page 6: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

6BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GreatReality#2:You’veGottoKnowAssembly¢ Chancesare,you’llneverwriteprogramsinassembly§ Compilersaremuchbetter&morepatient thanyouare

¢ But:Understandingassemblyiskeytomachine-levelexecutionmodel§ Behavior ofprograms inpresence ofbugs

§ High-level languagemodelsbreakdown§ Tuningprogramperformance

§ Understand optimizationsdone/notdonebythecompiler§ Understanding sourcesofprograminefficiency

§ Implementing systemsoftware§ Compilerhasmachinecodeastarget§ Operatingsystemsmustmanageprocess state

§ Creating/fightingmalware§ x86assemblyisthelanguageofchoice!

Page 7: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

7BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GreatReality#3:MemoryMattersRandomAccessMemoryIsanUnphysicalAbstraction

¢ Memoryisnotunbounded§ Itmustbeallocatedandmanaged§ Manyapplicationsarememorydominated

¢ Memoryreferencingbugsespeciallypernicious§ Effects aredistantinbothtimeandspace

¢ Memoryperformanceisnotuniform§ Cacheandvirtualmemoryeffects cangreatlyaffectprogramperformance§ Adaptingprogramtocharacteristics ofmemorysystemcanleadtomajorspeed improvements

Page 8: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

8BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

MemoryReferencingBugExample

§ Result issystemspecific

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

typedef 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;

}

Page 9: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

9BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

MemoryReferencingBugExampletypedef struct {

int a[2];double d;

} struct_t;

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

Locationaccessed byfun(i)

Explanation:

CriticalState 6

? 5

? 4

d7 ... d4 3

d3 ... d0 2

a[1] 1

a[0] 0

struct_t

Page 10: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

10BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

MemoryReferencingErrors

¢ CandC++donotprovideanymemoryprotection§ Outofboundsarrayreferences§ Invalidpointervalues§ Abusesofmalloc/free

¢ Canleadtonastybugs§ Whetherornotbughasanyeffect depends onsystemandcompiler§ Actionatadistance

§ Corrupted objectlogicallyunrelated toonebeingaccessed§ Effectofbugmaybefirstobserved longafter itisgenerated

¢ HowcanIdealwiththis?§ Program inJava,Ruby,Python,ML,…§ Understand whatpossible interactionsmayoccur§ Useordevelop toolstodetect referencing errors (e.g.Valgrind)

Page 11: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

11BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GreatReality#4:There’smoretoperformancethanasymptoticcomplexity

¢ Constantfactorsmattertoo!¢ Andevenexactopcountdoesnotpredictperformance

§ Easilysee10:1performance rangedependingonhowcodewritten§ Mustoptimizeatmultiplelevels:algorithm,datarepresentations,procedures, andloops

¢ Mustunderstandsystemtooptimizeperformance§ Howprogramscompiledandexecuted§ Howtomeasure programperformance andidentifybottlenecks§ Howtoimproveperformance withoutdestroyingcodemodularityandgenerality

Page 12: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

12BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

MemorySystemPerformanceExample

¢ Hierarchicalmemoryorganization¢ Performancedependsonaccesspatterns

§ Includinghowstepthroughmulti-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];}

81.8ms4.3ms 2.0GHzIntelCorei7Haswell

Page 13: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

13BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

WhyThePerformanceDiffers

128m32m

8m2m

512k128k

32k0

2000

4000

6000

8000

10000

12000

14000

16000

s1s3

s5s7

s9s11

Size (bytes)

Read

thro

ughp

ut (M

B/s)

Stride (x8 bytes)

copyij

copyji

Page 14: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

14BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GreatReality#5:Computersdomorethanexecuteprograms

¢ Theyneedtogetdatainandout§ I/Osystemcriticaltoprogramreliabilityandperformance

¢ Theycommunicatewitheachotherovernetworks§ Manysystem-level issuesarise inpresence ofnetwork

§ Concurrent operations byautonomousprocesses§ Copingwithunreliablemedia§ Crossplatformcompatibility§ Complexperformance issues

Page 15: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

15BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

CoursePerspective

¢ MostSystemsCoursesareBuilder-Centric§ ComputerArchitecture

§ Designpipelinedprocessor inVerilog§ OperatingSystems

§ Implementsampleportionsofoperatingsystem§ Compilers

§ Writecompiler forsimplelanguage§ Networking

§ Implementandsimulatenetworkprotocols

Page 16: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

16BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

CoursePerspective(Cont.)

¢ OurCourseisProgrammer-Centric§ Purpose istoshowthatbyknowingmoreabouttheunderlyingsystem,onecanbemoreeffective asaprogrammer

§ Enableyouto§ Writeprograms thataremore reliableandefficient§ Incorporate features thatrequirehooksintoOS

– E.g.,concurrency, signalhandlers§ Covermaterial inthiscourse thatyouwon’tseeelsewhere§ Notjustacourse fordedicatedhackers

§ Webringoutthehiddenhacker ineveryone!

Page 17: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

17BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

Textbook

¢ RandalE.BryantandDavidR.O’Hallaron,§ ComputerSystems:AProgrammer’sPerspective,ThirdEdition (CS:APP3e),Pearson, 2016

§ http://csapp.cs.cmu.edu§ Thisbookreallymatters forthecourse!

§ Howtosolve labs§ Practiceproblems typicalofexamproblems

Page 18: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

18BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

CourseComponents

¢ Lectures§ Higher levelconcepts

¢ Recitations§ Appliedconcepts, important toolsandskillsforlabs,clarification oflectures, examcoverage

¢ Homeworks (Labs)§ Theheartofthecourse§ 1-2weekseach§ Provide in-depthunderstanding ofanaspectofsystems§ Programmingandmeasurement

¢ Exams(midterm+final)§ Testyourunderstanding ofconcepts&mathematicalprinciples

Page 19: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

19BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

GettingHelp

¢ ClassWeb page:http://faculty.cse.tamu.edu/djimenez/312§ “Complete”schedule oflectures, exams,andassignments§ Copiesoflectures, assignments, exams, solutions§ Clarifications toassignments

¢ TeachingAssistants¢ PeerTeachers¢ OfficeHours¢ AskQuestionsinClass!

Page 20: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

20BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

RulesoftheLectureHall

¢ Laptops:permitted

¢ Electroniccommunications:forbidden§ Noemail,instantmessaging, cellphonecalls,etc

¢ Presenceinlectures,recitations:voluntary,recommended

Page 21: Course Overview - TAMU Computer Science People Pagesfaculty.cse.tamu.edu/djimenez/312/lecture1.pdf · Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third

21BryantandO’Hallaron,ComputerSystems:AProgrammer’sPerspective,ThirdEdition

WelcomeandEnjoy!