Download presentation
Presentation is loading. Please wait.
1
Computer Systems & Programming (CS 367)
Prof. Elizabeth White Spring 2016
2
Course Goals Previous courses:
CS 112, CS high-level programming in Java/C++ CS262 – C programming - Commonly used for “low-level” systems programming and embedded systems Theme of the course: strip away abstractions provided by high-level languages such as Java and let you understand what goes on “under the hood”
3
Course Goals cont’d Most CS courses emphasize abstraction
Abstract data types Asymptotic analysis Abstractions have limits Especially in the presence of bugs Need to understand underlying implementations Useful outcomes Become more effective programmers Able to find and eliminate bugs efficiently Able to tune program performance Prepare for later “systems” classes in CS & ECE Compilers, Operating Systems, Networks, Computer Architecture
4
Great Reality #1 Ints are not Integers, Floats are not Reals Examples
Is x2 ≥ 0? Floats: Yes! Ints: 40000 * > 50000 * > ?? Is (x + y) + z = x + (y + z)? Unsigned & Signed Ints: Yes! Floats: (1e e20) > 3.14 1e20 + (-1e ) --> ??
5
Computer Arithmetic Does not generate random values
Arithmetic operations have important mathematical properties Cannot assume “usual” 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
6
Great Reality #2 You’ve got to know assembly
Chances are, you’ll never write program in assembly Compilers are much better & more patient than you are Understanding assembly key to machine-level execution model 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!
7
Great Reality #3 Memory Matters 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
8
Memory Referencing Bug Example
double fun (int i) { double d[1] = {3.14}; long int a[2]; a[i] = ; /* Possibly out of bounds */ return d[0]; } zeus-1$ a.out 0 result: zeus-1$ a.out 1 zeus-1$ a.out 2 result: zeus-1$ a.out 3 zeus-1$ a.out 4 Segmentation fault (core dumped) zeus-1$ a.out 5 zeus-1$ a.out 6 Saved State d7 … d4 d3 … d0 a[1] a[0]
9
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, Lisp, or ML Understand what possible interactions may occur Use or develop tools to detect referencing errors
10
Memory Performance Example
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]; } void copyij(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]; } 21 times slower Pentium 4 Hierarchical memory organization Performance depends on access patterns Including how we step through multi-dimensional array
11
Great Reality #4 There’s more to performance than asymptotic complexity Constant factors matter too! And even exact op count does not predict performance Easily see 10:1 performance range depending on how code written Must optimize at multiple levels: algorithm, data representations, procedures, and loops Must understand system to optimize performance How programs compiled and executed How to measure program performance and identify bottlenecks How to improve performance without destroying code modularity and generality
12
Great Reality #5 They need to get data in and out
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 the presence of networks Concurrent operations by autonomous processes Coping with unreliable media Cross platform compatibility Complex performance issues
13
Course Perspective Most Systems Courses are Builder-Centric
Computer Architecture Design pipelined processor Operating Systems Implement portions of operating system Compilers Write compiler for simple language Networking Implement and simulate network protocols
14
Course Perspective (Cont.)
This 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 Not just a course for dedicated hackers We bring out the hidden hacker in everyone Cover material in this course that you won’t see elsewhere Linking, loading, signals If nothing else, this course will teach you how to make effective use of debuggers such as gdb
15
Relationship to other courses
16
Course Prerequisites You must have completed the following classes with a C or better grade: CS 262 – Introduction to Low-level Programming or CS Computer Programming for Engineers, ECE 301 – Digital Electronics The programming assignments in CS 367 involve machine and assembly language (x 86), and programming in C Things you should already know about C: C data types C Standard I/O library Bit-level operators Pointers & structures Dynamic memory allocation and deallocation How to use makefiles Unix commands
17
Randal E. Bryant and David R. O’Hallaron,
Textbook Randal E. Bryant and David R. O’Hallaron, “Computer Systems: A Programmer’s Perspective”, Prentice Hall 2009 – Third Edition This book really matters for the course! How to solve labs Practice problems typical of exam problems Optional book: a good reference on C like Brian Kernighan and Dennis Ritchie, “The C Programming Language, Second Edition”, Prentice Hall, 1988
18
Logistics Lectures Homework [10% of the course grade]
Small programs in C Written exercises Labs [35% of the course grade] The heart of the course 4 assignments - approx. 2 weeks each Provides an in-depth understanding of an aspect of systems Programming and measurement C
19
Lab Rationale Each lab has a well-defined goal. Completing the labs will result in new skills and a better understanding of course concepts. Each lab is to be an individual effort – ‘moss’ (and other software) may be used to detect unauthorized collaboration. All programs must be submitted and tested on zeus.vse.gmu.edu Even if it works on your laptop or PC, it doesn’t count unless it runs on the IT&E cluster. You will need to install and use the university VPN to access your account off campus.
20
Logistics Making Deadlines Exams and Final exams [30%+ 25%]
Assignments are due at the stated time and day. Some (not all) assignments can be turned in late with a penalty for each late day. Using ‘tokens’ to help manage late days (see syllabus) Exams and Final exams [30%+ 25%] Test your understanding of concepts & mathematical principles There are NO make ups for missing an exam without official documentation of your reason for missing.
21
Cheating What is cheating? What is NOT cheating? Penalty for cheating:
Sharing code: either by copying, retyping, looking at, or supplying a copy of a file. Coaching: helping your friend to write a lab, line by line. Copying or purchasing code from previous course or from elsewhere on WWW What is NOT cheating? Explaining how to use systems or tools. Explaining what is meant by the specifications. Looking at output and telling whether it is correct or not. Penalty for cheating: Removal from course with failing grade.
22
Getting Help Piazza Blackboard http://mymason.gmu.edu
Up-to-date information on the course Slides HW & Lab assignment Solutions to homework Your grades – be sure to confirm these are correct! Piazza Ask questions of instructors, TA, UTA, peers Course announcements will appear here
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.