DOC PREVIEW
Berkeley COMPSCI 61C - Lecture 2

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS61C Machine Structures Lecture 2Review 1/2Review 2/.2OverviewC vs. Java - DifferencesC PointersSlide 7Slide 8C Pointers and Parameter PassingSlide 10Administrivia 1/4Administrivia 2/4Administrivia 3/4Administrivia 4/4Computers in the NewsC Structures vs. Java ClassesSlide 17C Memory ManagementThe StackWho cares about stack management?The Heap (Dynamic memory)C Memory Allocation: malloc()C Memory AllocationOdds and Ends"And in Conclusion…"cs 61C L2 C intro.1Patterson Fall00 ©UCBCS61CMachine StructuresLecture 2September 1,2000Dave Patterson (http.cs.berkeley.edu/~patterson)http://www-inst.eecs.berkeley.edu/~cs61c/cs 61C L2 C intro.2Patterson Fall00 ©UCBReview 1/2°15 weeks to learn big ideas in CS&E•Principle of abstraction, used to build systems as layers •Pliable Data: a program determines what it is•Stored program concept: instructions are just data•Principle of Locality, exploited via a memory hierarchy (cache)•Greater performance by exploiting parallelism (pipeline)•Compilation v. interpretation to move down layers of system•Principles/Pitfalls of Performance Measurementcs 61C L2 C intro.3Patterson Fall00 ©UCBReview 2/.2°Continued rapid improvement in Computing•2X every 1.5 years in processor speed; every 2.0 years in memory size; every 1.0 year in disk capacity; Moore’s Law enables processor, memory (2X transistors/chip/ ~1.5 yrs)°5 classic components of all computers Control Datapath Memory Input Output}Processorcs 61C L2 C intro.4Patterson Fall00 ©UCBOverview°Review (2 minutes)°C Pointers (10 min)°Parameter Passing (8 min)°Administrivia Break (5 min)°Computers in the News (3 min)°C structures (10)°Memory Allocation (10 min)°Conclusion (2 min)cs 61C L2 C intro.5Patterson Fall00 ©UCBC vs. Java - Differences°C has no objects, no classes, no superclasses•Java method => C procedure, function°Variable, Array initialization•C: ? (sometimes zero, sometimes random)•Java: zero°Output•C: printf()•Java: system.out.print()°Memory management, pointerscs 61C L2 C intro.6Patterson Fall00 ©UCBC Pointers°Pointer: represents a raw memory address (more details later in course)°C variables can have pointer types:int *x; /* type: pointer to an int */int **x;/* type: pointer to a pointer to an int */int *x, *y, *z; /* type: pointers to ints */int *x, y, z; /* type: ? */°How create a pointer to store in a variable?•& operator: get address of a variable°int *x; /* type: pointer to an int */cs 61C L2 C intro.7Patterson Fall00 ©UCBC Pointers°How create a pointer to store in a variable?•& operator: get address of a variableint *x, y; y = 3; x ? y ?x ? y 3y = &x; x y 3°How get a value pointed to?•* dereference operator: get value pointed toprintf(“x points to %d\n”,*x);cs 61C L2 C intro.8Patterson Fall00 ©UCBC Pointers°How change variable pointed to?•Use dereference * operator to left of =*x = 5; x y 5°How get a address of the pointer?•Why do you want to do this???printf(“x pointer is %p\n”, x);°Closest thing in C to object type in Java:•void * is a type that can point to anything•Example: linked list in C with pointer to next node and a pointer to the value, but not sure what type it iscs 61C L2 C intro.9Patterson Fall00 ©UCBC Pointers and Parameter Passing°Java and C pass a parameter “by value”•procedure/function gets a copy of the parameter, so changing the copy cannot change the originalvoid addOne (int x); {x = x + 1;};int y = 3;y3addOne (y); xy3x4cs 61C L2 C intro.10Patterson Fall00 ©UCBC Pointers and Parameter Passing°How get a function to change a value?void addOne (int *x); {*x = *x + 1;};int y = 3;y3addOne (&y); xyx4cs 61C L2 C intro.11Patterson Fall00 ©UCBAdministrivia 1/4°Change in TAs, new people, shuffle sections (you asked for it)°Students who have not taken 61B:•Will be dropped from class if enrolled or not promoted from wait list°If you have taken 61B or the equivalent and you are on the list:•Petition Michael-David Sasson, 379 Soda, 643-6002, msasson@cs to petition today°61B Fall Semester meets in the same room, so it can easily add 100 people; more sections will be added as neededcs 61C L2 C intro.12Patterson Fall00 ©UCBAdministrivia 2/4°Instructor: David A. Patterson (patterson@cs) 635 Soda Hall Office Hours:Wed 1-2•Sally Mack (smack@cs), 626 Soda, x3-4034°Materials: http://www-inst.eecs/~cs61c°Lectures, projects, labs, homeworks on www-inst.eecs/~cs61c/schedule.html°Newsgroup: ucb.class.cs61c°Text: Computer Organization and Design: The Hardware/Software Interface, 2/ecs 61C L2 C intro.13Patterson Fall00 ©UCBAdministrivia 3/4°Must turn in survey, login and attend lab/discussion sections to be considered enrolled•Go to old and new sections to ask TA’s to switch sections °Lab exercises are to be done every week in lab section, and checked off by your lab TA or turned in at beginning of lab°Homework exercises are to be handed in either online or to homework boxes in 283 Soda, due on Mondays at noon; °Projects are larger programming assignments; individual and teamcs 61C L2 C intro.14Patterson Fall00 ©UCBAdministrivia 4/4°Course Exams•Midterm: Wednesday October 25(5-8 PM, 1 Pimentel)•Final: Tuesday, December 12 (5-8 PM, 1 Pimentel)°Class agreed upon punishment for•Cheating on Exercises, Labs, Projects-0 for assignment•Cheating on Exams-0 for examcs 61C L2 C intro.15Patterson Fall00 ©UCBComputers in the News°“Artificial Life Milestone: Robots Building Robots” For the first time, computer scientists have created a robot that designs and builds other robots, almost entirely without human help. In the short run, this advance could lead to a new industry of inexpensive robots customized for specific tasks. …Mimicking biological evolution, the computer added, subtracted and changed pieces in the designs. At the same time, the computer similarly mutated the programming instructions for controlling the robot's movements. After each step, the computer ran simulations to test the designs, keeping the ones that moved well and discarding the failures. “Some thing we probably can do we shouldn’t do”, Bill Joy… “We’re on the road to somewhere where there’s big issues…”N.Y. Times, front page, 8/31/00golem03.cs-i.brandeis.edu/download/AutomaticDesign.pdfwww.wired.com/wired/archive/8.04/joy.htmlcs 61C L2 C intro.16Patterson Fall00 ©UCBC Structures vs. Java Classes°Structure: Agglomerations of


View Full Document

Berkeley COMPSCI 61C - Lecture 2

Documents in this Course
SIMD II

SIMD II

8 pages

Midterm

Midterm

7 pages

Lecture 7

Lecture 7

31 pages

Caches

Caches

7 pages

Lecture 9

Lecture 9

24 pages

Lecture 1

Lecture 1

28 pages

VM II

VM II

4 pages

Midterm

Midterm

10 pages

Load more
Download Lecture 2
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 2 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 2 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?