Unformatted text preview:

CS262 Lecture 01IntroductionZoran DuricDepartment of Computer ScienceIntroduction to Low-level Programming• instructor: Zoran Duric• [email protected]• Office: ENGR 4443• Office hours: T,R 3-4pm, Wed. 10:20-11:20am• TA’s office hours will be posted soon2Introduction to Low-level Programming• Monday/Wednesday 9:00 am - 10:15 pm • Robinson Hall B208• this class only meets 10 weeks and ends at April 16, 2012• Last day to drop without penalty: Jan 31, 2012• Course webpage: – http://www.cs.gmu.edu/~zduric/cs262.html3Prerequisites• C or better in – CS 211 (OOP) or – CS 222 (Programming for Engineers)• No exceptions4Course Scopes• Most high-level programming languages insulate the programmer from the realities of the hardware on which the programs will run• Examples are:– memory management– file system management– process management– hardware signals5Course Scopes• C is the exception since it was originally designed to implement the Unix operating system• C offers the programmer direct access to much of the underlying hardware and, for programs running under Unix, direct access to operating system services6Course Scopes• For these reasons C remains the language of choice for systems programming. – What are other reasons?– What are your reasons?7Course Scopes• This is a (short) course on "low-level" programming using C• We will learn C with heavy emphasis on pointer operations, i.e.,– how to allocate, manipulate, free memory without crashing your code8Course Outcomes• Be able to implement, test and debug a designed solution to a problem in a low-level programming language, specifically the C programming language.• Demonstrate a good understanding of C language constructs such as pointers, dynamic memory management, and address arithmetic.9Course Outcomes• Demonstrate a good understanding of C libraries for input and output, and the interface between C programs and the UNIX operating system.• Demonstrate an ability to use UNIX tools for program development and debugging– vi, emacs, jEdit10TextBook• Brian Kernighan and Dennis Ritchie, The C Programming Language, 2nd ed., Prentice Hall, 1988 (a.k.a. K&R)11• Dennis Ritchie from AT&T Bell Lab is the inventor of C• Professor, Department of Computer Science Princeton University PrincetonTopics• C Types, Operators, and Expressions• Control Flow • Functions and Program Structures• Pointers and Arrays• Dynamic memory allocation• Structures• Bitwise operations• Input and Output Libraries• The Unix System Interface12Gradinglabs: 20%• lab attendance is mandatory • quizzes: 10%• will be occasionally given during labs• projects: 25%• midterm exam: 20%• final exam: 25%13Policies• All required assignments should be completed by the stated due date and time• The total score of your assignment score will be 10 points less every extra day after the due date – i.e., the 100 total points will become zero after 10 days pass the due date• You are responsible for keeping backups of your work – my disk crashed" and "my roommate ate my program" are not reasons for late submissions14Policies• You can only turn in a program once. • No revisions or additions can be made to your program after it has been submitted.15Policies• All coursework is to be done independently• You are encouraged to discuss the material BEFORE you do the assignment• The homework should be written strictly by yourself • Plagiarizing the homework will be penalized by maximum negative credit and cheating on the exam will earn you an F in the course.16A bit History• born in the Computer Science Research Department of Bell Labs in Murray Hill, NJ17A bit of History• C was created with Unix in mind18A bit of History• Standardized in 1989 by ANSI (American National Standards Institute) known as ANSI C• International standard (ISO) in 1990 which was adopted by ANSI and is known as C89• As part of the normal evolution process the standard was updated in 1995 (C95) and 1999 (C99)• C++ and C– C++ extends C to include support for Object Oriented Programming and other features that facilitate large software development projects– Unfortunately, there are two ISO committees for C and C++.19Elements of a C Program• A C development environment includes – System libraries and headers: a set of standard C libraries and their header files. •For example see /usr/include and glibc.– Application Source: application source and header files– Compiler: converts source to object code for a specific platform– Linker: resolves external references and produces the executable module20Elements of a C Program• There must be one main function where execution begins when the program is run.– int main (void) { ... },– int main (int argc, char *argv[]) { ... }– UNIX Systems have a 3rd way to define main(), though it is not POSIX.1 compliant• int main (int argc, char *argv[], char *envp[])• Preprocessors– macros, compiler controls, constant values• additional local and external functions and variables21Example Code• see example code22Pitfalls of C• Great power comes with great responsibility• C is procedural language, it easy to write spaghetti code• Preprocessors can get really messy• no way to gracefully terminate a program– no catch/throw/exception• not too many (there are some) help from the language for doing OOP/OOD• Many others... (Recommend reading: C Traps and Pitfalls, by Andrew Koenig)23Your Tasks This Week• We will use only gcc• Your assignments will be compiled using gcc -c89• gcc is available on (virtually) all systems. This includes the – mason cluster, – Linux, – Windows (you must install Cygwin), and – Mac OS X (you must install Xcode).24Your Tasks This Week• Learn basic Unix commands: ls, pwd, cp, cat, less, scp, ssh• Learn about Makefile– GNU `make'– a power build system– determines automatically which pieces of a large program need to be recompiled, and issues the commands to recompile them– this is very useful if you have many header files and source


View Full Document

MASON CS 262 - Lecture 1 Introduction

Download Lecture 1 Introduction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 1 Introduction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 1 Introduction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?