Computer Systems and Programming - Lecture Slides | CS 367, Study notes of Computer Science

Material Type: Notes; Professor: Carver; Class: Computer Systems and Programm; Subject: Computer Science; University: George Mason University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 02/12/2009

koofers-user-z1k
koofers-user-z1k 🇺🇸

10 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Systems &
Programming (CS 367)
Prof. Richard Carver
George Mason University
1-2
Course Goals
Previous courses (CS 112, CS 211): high-level
programming in Java/C++
This course: exposes you to C and assembly
programming
C is a procedural language (not object-oriented)
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”
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Computer Systems and Programming - Lecture Slides | CS 367 and more Study notes Computer Science in PDF only on Docsity!

Computer Systems &

Programming (CS 367)

Prof. Richard Carver

George Mason University

1-

Course Goals

Previous courses (CS 112, CS 211): high-level

programming in Java/C++

This course: exposes you to C and assembly

programming

  • C is a procedural language (not object-oriented)
  • 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”

1-

Course Goals cont’d

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

1-

Great Reality #

Int’s are not Integers, Float’s are not Reals

Examples

  • is x^2  0?  Float’s: Yes!  Int’s: - 40000 * 40000 --> 1600000000 - 50000 * 50000 --> ??
  • is (x + y) + z = x + (y + z)?  Unsigned & Signed Int’s: Yes!  Float’s: - (1e20 + -1e20) + 3.14 --> 3. - 1e20 + (-1e20 + 3.14) --> ??

1-

Great Reality #

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

1-

Memory Referencing Bug Example

main () { long int a[2]; double d = 3.14; a[2] = 1073741824; / Out of bounds reference / printf("d = %.15g\n", d); exit(0); }

main () { long int a[2]; double d = 3.14; a[2] = 1073741824; / Out of bounds reference / printf("d = %.15g\n", d); exit(0); }

Alpha MIPS Linux -g 5.30498947741318e-315 3.1399998664856 3. -O 3.14 3.14 3.

(Linux version gives correct result, but implementing as separate function gives segmentation fault.)

1-

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

1-

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

1-

Textbooks

Randal E. Bryant and David R. O’Hallaron,

  • “Computer Systems: A Programmer’s Perspective”, Prentice Hall 2003.
  • csapp.cs.cmu.edu

Brian Kernighan and Dennis Ritchie,

  • “The C Programming Language, Second Edition”, Prentice Hall, 1988
  • You can use any book on C

1-

Course Outline

Programming in C (2 weeks)

Data Representation (2 weeks)

Program Representation (5 weeks)

Linking (1 week)

Exceptional Control Flow & Virtual Memory (3 weeks)

1-

Programming in C

Assumption: You are comfortable programming in Java

and/or C++

C is a procedural (imperative) programming language

Topics

  • C Standard I/O library for input/output
  • Bit-level operators
  • Pointers & Structures
  • Memory allocation and deallocation

Assignment

  • P1: Write a non-trivial program in C

1-

Machine-level Representation of Data and

Programs

Topics

  • Bits operations, arithmetic, assembly language programs, representation of C control and data structures
  • Includes aspects of of architecture and compilers

Assignments

  • Lab

1-

Logistics

Grading

  • Programming Assignments and Homework (50%)  All programs will be tested on a Linux platform for grading - You need to obtain an IT&E Unix Cluster account (See syllabus)
  • Midterm (25%) & Final (25%) Class TA
  • Raimi Rufai ([email protected])
  • Office Hrs: TBD My office hrs
  • T 3:45-4:30pm, S&T II, Room 343
  • Also available at other times (e.g., before class)
  • Always available via email

1-

Policies

Classroom:

  • Set phones to vibrate mode if you must leave them on

1-

Cheating

What is cheating?

  • Sharing code: either by copying, retyping, looking at, or supplying a copy of a file.

What is NOT cheating?

  • Helping others use systems or tools.
  • Helping others with high-level design issues.
  • Helping others debug their code.

Penalty for cheating:

  • Removal from course with failing grade.

1-

Logistics cont’d

Class Web Page

  • http://www.cs.gmu.edu/~rcarver/cs
  • Lecture Slides, Assignments, Useful Links