1 / 70

APS105

APS105. Introduction. Welcome. To University and UofToronto To Engineering To APS105. About your Prof. Prof. Greg Steffan PhD Computer Science, Carnegie Mellon, 2003 BASc / MASc , ECE, UofToronto , 1995/1997 Research Making multicores and FPGAs easier to program Contact:

spence
Télécharger la présentation

APS105

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. APS105 Introduction

  2. Welcome • To University and UofToronto • To Engineering • To APS105

  3. About your Prof • Prof. Greg Steffan • PhD Computer Science, Carnegie Mellon, 2003 • BASc/MASc, ECE, UofToronto, 1995/1997 • Research • Making multicores and FPGAs easier to program • Contact: • steffan@eecg.toronto.edu • Office: EA321 • Office hours: wed 12-1pm

  4. Why Learn About Programming and C?

  5. Why Learn Programming? • Computers: our most powerful technology • Learn to command them to do your bidding! • For love of design • Programming is pure design with few limitations • “only slightly removed from pure thought-stuff” • Entrepreneurial opportunities • Start a company in your bedroom with no $$$ • Many engineering jobs involve programming • Simulations, databases, websites • Whether civil, electrical, mechanical…

  6. Why Learn C? • Lots of other newer, sexier languages • Java, Python, Ruby, javascript • Benefits of C: • “Compiled language”, not “interpreted” • Close to the hardware with no layers between • Easier to understand what is happening • Important building-block for later computing courses • C/C++ still very common • In high-performance applications • In low-level code like operating systems, databases,… • C-like-syntax found in many of above languages

  7. Why Attend Lectures? • To see someone else think through problems • Different than simply seeing the solution • Learn “why”, not just “how” • how course material fits in with “big picture” • Will provide proper emphasis • Highlight key material • Overview-only sundry material • Will teach material in order of importance • Eg., order that you need it for labs • Ideally more entertaining than reading manual • Else Prof-fail.

  8. Administration

  9. Course Website • Portal.utoronto.ca • APS105FALL 2011 • Any Handouts • Lab Assignments • Past Exams • Form for missed labs/quizzes • Form for misgraded midterm • Discussion Board

  10. Course Meetings • Lecture Periods: • three one-hour lectures per week • Start at 10mins after the hour • Optional Lecture: • review of regular lecture material • attendance recommended for non-experts • tuesdays 3-4pm MC102 (entire course invited) • Tutorial Periods: • One per week, run by TAs • Quizes in about half of the tutorials • Attendance optional, unless there is a quiz • Lab Periods: • Two hours per week • TAs available to answer questions • Attendance "mandatory"

  11. Evaluation • Quizzes: 8% • 4 total • Given in tutorials • Based on lecture material since last quiz • Labs: 17% • 8 total • Midterm: 25% • Final Exam: 50% • Emphasis on 2nd half of course

  12. Lecture Slides and Note-Taking • Electronic slides with fill-in-the-blanks • A hybrid between powerpoint and chalkboard • Pptx/pdf available on www prior to lecture • Please print and bring to class • The filled-in “blanks” are only during class • Filled-in slides will not be published • The symbol that indicates a blank to fill

  13. Course Textbook • “An Introduction to Computer Science Using C”, 2nd Edition • by John Carter • Published by McGraw Hill-Ryerson • How to get a copy: • UofT bookstore • basement of Sandford Fleming Building • Amazon etc.

  14. Labs (programming assignments) • There are 8 of them in total • You will always be working on one • Must run properly on ECF systems • Even if it runs fine elsewhere • Marks for functionality and style • Proper style will be defined throughout term

  15. Cheating/Copying • Easy to do, equally easy to catch! • “cheater-beater” software • Automatically compares all submissions • we do actually do this, and do follow through! • the interview and punishment process is painful for all! • You only cheat yourself • Labs worth 1.6% each • The practice you get by doing them is invaluable • The consequences for being caught are harsh • See Engineering Calendar for details

  16. Getting Help • See course info handout • Meet some friends: “study groups” • Collaborating vs cheating • Ask questions in class • Point out confusing things and mistakes! • Get help quickly if you get into trouble • First-year office (1st floor Galbraith Building) • www.calss.utoronto.ca • Help with academics, personal

  17. In-Class Etiquette • Be on time • Class starts at 10mins after the hour • Quiet please! • Silence yourself and all electronic devices! • Pay attention • Eg., watching youtube on laptop distracts others • Ask questions and point out errors! • Raise your hand • Say “question!” if I don’t notice

  18. How to Succeed at APS105 • Attend lectures • take notes, ask questions • Do labs yourself, on-time • Practice/experience is invaluable • Review lecture material regularly • Be better prepared for quizes/midterm/final • Avoid last-minute cramming • Prepare for midterm/final • Practice by trying past midterms/finals • Practice by filling lecture slides on your own • Both available on www

  19. How to Succeed at Skule (computing) • Learn to keyboard properly! • Learn unix/linux basics • see the unix handout • has details on how to log in from home • Learn some javascript • For programming www page features • Write a simple app for your own use • Eg., for your laptop or iphone

  20. Computer Systems Basics

  21. Computer Systems Stack

  22. Programmer Compiler Machine Instructions Processor 0100101 Add r3,r3,r1 Cmp r3,r1 Bge 0x3340a Mulu r3,r5,r2 Sub r1,r3,r4 … How We Tell a Processor What to Do int Foo (int x){ return x + 5; } … Processors execute machine instructions encoded in binary

  23. Monitor A TYPICAL PC Graphics card Motherboard (CPU, MEMORY) Hard drive CD/DVD R/W USB Connectors Keyboard Mouse Power Supply

  24. CPU Memory (RAM) Simple View of a Motherboard • Memory: • holds bits • can be read from or written to • CPU: • datapath: arithmetic/logic units (add, sub), etc. • control circuitry

  25. C

  26. About C • Invented in Bell Labs (in 1970s) • by Dennis Ritchie • Inherits from earlier language • called “B” • C++ • an extension of C • Supports “object oriented programming” Dennis Ritchie

  27. Hello World .

  28. Alternative Hello World .

  29. GCC • gcc • Means “GNU C compiler” • A program that converts C to 0’s & 1’s • Stored in a file called an “executable” • Type this command to compile hello.c • Generates the executable file • Insteady you could type: • Generates the executable file

  30. Value Representation

  31. Bits and Bytes • “bit” is short for “binary digit” • A bit can be 0 or 1 • Why do computers use bits? • A byte is a group of 8 bits • 1 byte can be written as 1B

  32. RECALL: BASE 10 (decimal) • 956 • NOTE: not all languages/cultures use base10 • Ndom, FrederikHendrik Island: base6 • nimbia: base12 • Huli, Papua New Guinea: base15 • Tzotzil, Mexico: base20 • Computers use base2 (binary)

  33. USING BINARY (BASE 2) • denoted by ‘0b’ (in this course, in C-code) • Converting from binary to decimal: • 0b1011

  34. Questions • How many decimal numbers can you represent with N bits? • NOTE: • computers can only represent finite numbers!

  35. Byte Size • 1byte = 1B = 8bits

  36. What is this? 10010010

  37. Types

  38. Types • Data Type: • tells computer how to interpret a group of bits • Without a type they are just bits! • C has types: • Basic data types: built-in, already defined for you • User-defined types: name your own! (later) • Basic data types: • A single value of a certain size (bytes) • Example: a number or a character

  39. Integer Types • int: 32bits, values: -231 .. 231-1 • We will almost always use int in this class • Other integer types: • unsigned int: 32bits, values 0.. 232-1 • short: at least 16bits • long: at least 32bits • long long: at least 64bits • what does "at least" mean? • the actual size can depend on the system!!!!!

  40. Floating Point Types • How to use binary to represent real numbers? • Eg., 1.3333333333333…. • Can’t: approximate, with limited accuracy • Floating-point: a common approximation • A value (mantissa) and an exponent • Flexible: can represent very big or very small • Eg., 2.1313*1020 or 2.1313*10-20 • We don’t need to know the details for this class

  41. Floating Point Types in C • double: at least 64 bits • We will almost always use double in this class • float: at least 32 bits

  42. Character Type • representing keyboard characters: • Eg: a,b,c,d…A,B,C,D, !@#$% • Standard encoding called ASCII: • eg., ‘A’ = 65 = 0100 0001 (binary) • char: 8 bits, typically ASCII-encoded • Note1: char holds only a single character • How can we represent a “string” of characters? • Note2: recall “escapes” • Eg., ‘\n’ represents the return character • Encoded as a single ASCII value

  43. Boolean Type • Often you want to represent true/false • The old way: use int values 0 and 1 • The new way: use the bool type • bool type • Has values ‘true’ and ‘false’ • Note: you have to include the bool library • in program (at top): #include <stdbool.h>

  44. Identifiers and Variables

  45. Identifiers • Identifiers give names to things • Choosing good names is a key skill! • Rules: identifiers can be • any length (any number of characters) • upper & lower case letters, digits, ‘_’ • First character cannot be a digit • Cannot match a C “reserved” word (like “int”)

  46. Choosing Identifiers: Good Style • Use upper-case to separate words: • Or use underscores to separate words: • Avoid easily-confused characters: • Choosing good identifiers is an art:

  47. Declaring Variables • Variable: storage of a value of a certain type • Variable declaration: • specifies that you plan to use a variable • and you would like it to be a certain type • Note: the C-compiler creates storage for it • General form: <type> <identifier list>;

  48. Declaring Variables: Examples • Example declarations:

  49. Assigning Values • Can assign a value at declaration, or later • Example assignment at declaration: • Example assignment at a later point: • Accuracy:

  50. Output

More Related