Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION Introduction to Systems Programming - COMP 1002, 1402 Instructor : Behnam Hajian

Similar presentations


Presentation on theme: "INTRODUCTION Introduction to Systems Programming - COMP 1002, 1402 Instructor : Behnam Hajian"— Presentation transcript:

1 INTRODUCTION Introduction to Systems Programming - COMP 1002, 1402 Instructor : Behnam Hajian bhajian@scs.carleton.ca

2 Objectives and syllabus The objectives in this course is:  To expose students to lower level systems interface only clearly visible via C.  To further develop the ability to design programs with emphasis on the abstract view of data structures.  To get experience with the low-level implementation of data structures in C.  To experience programming in the Large

3 Objectives and syllabus (continue) In this course you will learn:  The structure of a C program  How to use C/C++ compilers such as MinGW, Cygwin, GCC,…  How to execute a C program by platforms such as Borland C builder, Netbeans IDE, GCC,…  Variables and memory allocation  Type conversion, operators  control statements in C (if-then-else, while, for)  Function and Procedure, Call by Ref. and Call by Value, Input, Output

4 Objectives and syllabus (continue)  Header files, System and Library Calls  Structs and complex data structure  Arrays and String (1-D, 2-D, n-D array)  Pointers and more on dynamic memory allocation, and de-allocation  Heap, Stack  Linked lists Manipulation

5 Evaluation and…  5 programming assignments : 50%  Final Exam: 50% Website:  Course material will be available on WebCT: look for the WebCT link from Carleton’s web site. Lectures:  Tuesday & Thursday 6PM - 9 PM @ 502 Southam Hall Office hours:  The hour before lecture. @ HP 5270 or HP 5336

6 TA  Jimin Park  Email: jiminparky@gmail.comjiminparky@gmail.com  Mon & Fri 2-4 PM

7 TextBook References:  PPT slides are the most important resource for final exam. However, reading the textbook is highly recommended. TextBook:  C How to Program, 5 th Edition, Harvey M. Deitel and Paul J. Deitel, both from Deitel & Associates, Inc.

8 Computers  What is a computer?  A computational device  Logical decisions billions of times faster than humans  Hardware keyboard, screen, disks, memory, CPU  Software email, word processing, spreadsheets, OS

9 Computer Organization  Input unit  keyboard, microphone  Output unit  screen, printer  Memory unit  Random Access Memory (RAM) short-term, rapid access, low capacity warehouse  Read only memory ROM Smaller amount of memory stable when power off. Stores enough code to boot system

10 Computer Organization  Secondary storage unit  disks, tapes long-term, slow access, high capacity warehouse  Central Processing Unit (CPU): Microprocessor (Intel Pentium, Motorola power PC): fetches machine instructions from memory, executes them  Arithmetic and logic unit (ALU) calculations, comparisons  CU (Control Unit) coordinator, administrator,

11 Computer Architecture CPU Program Control Unit ALU MemoryI/O

12 Computer Architecture (cont.)

13 Computing Modes  Batch Processing  one job at a time  Multiprogramming  many jobs simultaneously  Timesharing  multiple jobs, multiple users  Personal computer (PC)  standalone units  Distributed computing  workload distributed over networks  Client/Server  client machine provides user interface  server machine provide computational power and storage location

14 Programming Languages  Machine Language  machine/hardware dependent  Too hard to program in  Assembly Language  English-like operations (e.g., load, store, add)  High-level languages  single statement can accomplish substantial tasks  English-like statements with mathematical notations

15 Why C?  Because we have to! C supports:  Many situations where it is only language or system available Small, embedded systems, instrumentation, etc.  Many “low-level” situations that don’t have support for “high-level” languages Operating systems, real-time systems, drivers

16 Why not C?  C is very low-level Data structures must be programmed “by hand” e.g. set,collection,… Operations must be done out in “long hand” No support for “object oriented” design Marginal support for higher-level thought processes Much, much harder to use than higher level languages/systems  Better alternatives available for almost all applications Java, Python, Ruby, etc. – many CS situations Matlab, SimuLink – physical modeling LabView – instrumentation and control Excel – accounting and statistics SQL – billing and transactions …

17 What about C++?  Object-oriented thinking Data abstractions, classes, objects, interfaces Operator overloading Inheritance Lots of other good stuff …  Backward compatible with C To some extent Allows programmer to get close to hardware when needed Allows programmer to get close to data representation when needed Not platform independent (like Java) Still need to be conscious of memory management …

18 C Program Development Environment Standard Steps 1. Edit 2. Preprocess 3. Compile 4. Link 5. Load 6. Execute

19 19 A Short History  In the beginning … Machine language Assembly language One line per machine instruction  So “high level” languages were invented Non-recursive:– Fortran, Cobol Recursive:– Algol, Lisp, Snobol, PL/1, etc. Really primitive! Too difficult for big projects Too advanced! Too much infrastructure for operating systems, control systems, many kinds of projects

20 C: History 20  Developed in the 1970s – in conjunction with development of UNIX operating system  When writing an OS kernel, efficiency is crucial This requires low-level access to the underlying hardware: e.g. programmer can leverage knowledge of how data is laid out in memory, to enable faster data access  UNIX originally written in low-level assembly language – but there were problems: No structured programming (e.g. encapsulating routines as “functions”, “methods”, etc.) – code hard to maintain Code worked only for particular hardware – not portable

21 C: Characteristics 21  C takes a middle path between low-level assembly language…  Direct access to memory layout through pointer manipulation  C is Concise syntax, small set of keywords  Is also a high-level programming language like Java:  Block structure  Some encapsulation of code, via functions  Type checking (pretty weak)

22 C: Dangers 22  C is not object oriented!  Can’t “hide” data as “private” or “protected” fields  You can follow standards to write C code that looks object- oriented, but you have to be disciplined – will the other people working on your code also be disciplined?  C has portability issues  Low-level “tricks” may make your C code run well on one platform – but the tricks might not work elsewhere  The compiler and runtime system will rarely stop your C program from doing stupid/bad things  Compile-time type checking is weak  No run-time checks for array bounds errors, etc. like in Java

23 QUESTIONS?


Download ppt "INTRODUCTION Introduction to Systems Programming - COMP 1002, 1402 Instructor : Behnam Hajian"

Similar presentations


Ads by Google