Course Overview CSC 2700 Systems Programming 1 st



















- Slides: 19
Course Overview CSC 2700 Systems Programming 1 st Lecture Instructor: David Trammell, Ph. D 1
Contact Info ¢ ¢ Syllabus Email is my preferred method of contact: davidst@csc. lsu. edu Office Hours: appointments or walk-ins: 3324 G PFT ¢ Office Phone: 225 -578 -5351 ¢ 2
Text Book ¢ Computer Systems: A Programmers Perspectives, Bryant & O'Hallaron 3 rd Ed. , 2016 (3 rd edition required!) ¢ Errata! http: //csapp. cs. cmu. edu/3 e/errata. html ¢ Learning Objectives / Topics 3
Grading Assignments (homework, programming, labs): 35% ¢ Quizzes (2 or 3) 15% ¢ Mid-term exam 25% ¢ Final exam 25% ¢ Participation >= +2. 5% ¢ -----------------------------------¢ TOTAL >= 102. 5% ¢ 4
Assignments and Participation ¢ Handwritten work (homework, quizzes, tests) must be reasonably neat and legible. Programs must compile! ¢ Use consistent style (indenting and so on), comments, etc. ¢ I might give style recommendations on early assignments and possibly deduct later if you don’t follow them ¢ ¢ PARTICIPATION (bonus points) ¢ The final exam is Thursday, May 3 rd, 12: 30 to 2: 30 pm 5
Linux notes ¢ ¢ The classes. csc. lsu. edu server is a Linux server Basic commands: pwd, ls, mkdir, cd, touch, mv, cp, man, echo § Tab completion ¢ Scripts: p_copy, verify, speak, <custom> § ~cs 2700_tra/bin/p_copy N § ~cs 2700_tra/bin/verify N § ~cs 2700_tra/bin/speak “your question or answer here” Text editing: vi/vim preferred ¢ More commands: ps, kill <PID> ¢ 6
Programming in C An interesting and useful book (not required) ¢ The C Programming Language, 2 nd Edition, Prentice Hall, 1988 § By Brian Kernighan and Dennis Ritchie § The C language as described by its creators (arguably still the best book) 7
1. 1 Bits + Context (1 of 2) ¢ What is 5454035? 8
1. 1 Bits + Context (2 of 2) ¢ 545 -4035 ¢ 5, 454, 035 ¢ $5, 454, 035 9
Abstraction vs. Reality ¢ Most CS courses emphasize abstraction § Abstract data types § Asymptotic analysis, etc. ¢ Abstractions have limits (int: ~~ -2 bil to +2 bil) § Ignoring limits leads to bugs ¢ Useful outcomes from taking Systems Programming § Avoid, discover and eliminate obscure bugs § Use CPU and memory more efficiently § Prepared for later “systems” classes such as Compilers, Operating Systems, Networks, Computer Architecture, Reverse Engineering, Malware Analysis and more 10
Ints are not Integers, Floats are not Reals ¢ Cannot assume usual mathematical properties § Ints are finite; Integers are infinite § Ints and Integer operations both satisfy “ring” properties for (+ - x) Commutative, associative, distributive § Integers preserve signs, but Ints don’t always do so (see example 1): § ¢ Example 1: Is x 2 ≥ 0? § True for Integers (in math), Reals and even Float/Double? Yes! § For Ints? 40000 * 40000 = 1, 600, 000 § 50000 * 50000 = 2, 500, 000? § No! Max Int is: 2, 147, 483, 647 § 11
Ints are not Integers, Floats are not Reals ¢ Floating point operations do not satisfy ring properties § What is 1/3 in decimal with floating point? ¢ Example 2: Is (x + y) + z = x + (y + z)? § Unsigned & Signed Int’s (and of course, Integers): Yes! § Float’s? (1 e 20 + -1 e 20) + 3. 14 --> 3. 14 § 1 e 20 + (-1 e 20 + 3. 14) --> 0 § ¢ Floating point operations maintain ordering (that is: sign) Overflow leads to positive or negative “infinity” § Underflow leads to +0. 0 or -0. 0 § 12
Assembly Language ¢ Chances are, you’ll never write real programs in assembly § Compilers are much better & more patient than you are ¢ However, understanding assembly is still important § Many bugs or security holes occur due to low level details § Critical areas of programs can be tuned in assembly, or tuned in a higher level language based on a knowledge of assembly § Understand enable or disable compiler optimizations § Understanding sources of program inefficiency § Fighting malware § x 86 assembly is used 13
Memory Matters ¢ Memory is not unbounded § It must be allocated and managed § Many applications are memory dominated ¢ Memory referencing bugs especially pernicious § C and C++ do not provide memory protection § No array index checks; no pointer validity checks, etc. ¢ 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 14
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 § 15
Memory System Performance Example void copyij(int { int i, j; for (i = 0; i for (j = 0; dst[i][j] } src[2048], dst[2048]) < 2048; i++) j < 2048; j++) = src[i][j]; 4. 3 ms void copyji(int { int i, j; for (j = 0; j for (i = 0; dst[i][j] } src[2048], dst[2048]) < 2048; j++) i < 2048; i++) = src[i][j]; 81. 8 ms 2. 0 GHz Intel Core i 7 Haswell 16
Why The Performance Differs copyij Read throughput (MB/s) 16000 14000 12000 10000 8000 copyji s 1 Stride (x 8 bytes) s 2 6000 4000 s 3 s 4 s 5 s 6 s 7 2000 s 8 s 9 s 10 s 11 0 17
System I/O ¢ We need to get data in and out § The I/O system is critical to program reliability and performance ¢ Communication over networks Concurrent operations by autonomous processes § Coping with unreliable media § Cross platform compatibility § Complex performance issues § 18
Next Week: Binary Representation of Data ¢ Read pages 2 to 28 § Asides provide optional history of Unix, C, GNU, and Linux § Skip section 1. 9. 1 on Amdahl’s Law (and its aside) ¢ Before leaving: § Did you get a computer account? § Questions about program submission system? § See me before leaving if needed 19