Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Stotts Computer Science Department UNC Chapel Hill.

Similar presentations


Presentation on theme: "David Stotts Computer Science Department UNC Chapel Hill."— Presentation transcript:

1 David Stotts Computer Science Department UNC Chapel Hill

2

3

4

5

6

7 Afraid you will become this guy 

8

9 http://www.cs.unc.edu/~stotts/COMP110-f15/ Class webpage

10 1. data storage (variables, assignment) 2. data retrieval (expressions, evaluation) 3. repetition (loops) 4. decision making (conditionals) 5. procedure abstraction (functions) 6. data abstraction (arrays)

11 No not this…

12  A “model” is a simplification of something complex… an abstraction  We take out some detail to show the basics of something in simple form  Details we remove are irrelevant to the aspects we wish to emphasize or explain in the model

13 enroll graduate Pay tuition Take fall classes Take spring classes Do 4 or 5 times Get 1.7 mil emails from Alumni Assoc

14 What can we study here? What can we not study?

15

16

17 planetscale sizeperihelionaphelion The Sun 10cm diameter 40 watt bulb 00 Mercury1/3mm paint drop10 3/4 feet16 1/4 feet Venus1mm paint drop25 feet25 1/2 feet Earth1mm paint drop34 1/2 feet35 2/3 feet Mars1/2mm paint drop48 feet59 feet Jupiter 10mm white marble or bead 173 feet191 feet Saturn 8 1/2mm hatpin or pearl 316 feet353 feet Uranus 3 1/3mm map pin or pearl 642 feet705 feet Neptune 3 1/5mm map pin or pearl 1045 feet1063 feet Scale Model of the Solar System Scale = 1:14,000,000,000 I miss Pluto … don’t you?

18 John

19

20

21

22

23

24

25 storage size increases access time increases cost decreases (per bit) persistence increases decreasing frequency of access by processor The “cloud”

26 CPU regs cache Main memory RAM Disk drives, DVD Network, cloud USB

27  A minimum amount of information is read from secondary memory into main memory  Control is transferred to that area of main memory; this code reads the core of the OS, called the kernel  The kernel executes the initial process  This process loads a full OS off disk (or cloud)  Called bootstrapping (pulling oneself up by one’s bootstraps)… the computer “boots up”  OS then runs all the other programs you write and use… including JavaScript

28 Main memory RAM kernel CPU Disk OS loads kernel CPU runs kernel Kernel talks to disk CPU runs full OS OS Keyboard Mic camera User input Data to programs Data output wireless, usb, net, print port, sound, video CPU runs programs

29 Intructions and data all stored in main memory (RAM)

30

31  Internally a computer stores information in binary form, or base 2  Here’s what a program in memory looks like if you could peek in:

32

33  We group the 0’s and 1’s into chunks to represent different forms of information

34 Programs and their data all stored together in memory  Some 0’s 1’s chunks stand for numbers  Some stand for characters, text  Some stand for images, videos, etc.  Some stand for memory locations  Some stand for program instructions like “add 2 numbers” or “save register 5 to memory location 2145768”

35  Computer sorts it all out during the fetch-execute cycle  When we “program” the computer we express the computations we want in a “high level” language like JavaScript  A compiler or translator converts our human-readable program into a big pile of binary… puts it in memory for the computer to then sort out and run

36  “0” and “1” are the way computers express information because of physics  A light switch is on, or it is off  A wire has current in it, or it does not  A spot on a disk surface is magnetic, or it is not  A hole is punched in a card, or it is not  “0” is really “absent” or “off”  “1” is really “present” or “on”  We also often think of “0” as false, “1” as true

37  With two physical states in a circuit (on, off) we must build all information from a notation with 2 units, or base 2  We call this binary  We think of the units as the digits 0 and 1  A single unit of information is a bit which is short for binary digit  We clump bits together into chunks sized by powers of 2

38 2^0 is 1 2^4 is 16 2^7 is 128 2^1 is 2 2^5 is 32 2^8 is 256 2^2 is 4 2^6 is 64 2^9 is 512 2^3 is 8  special… we call 8 bits a byte 2^10 is 1024  kilo, 1 kilobit, or 1 Kb 2^20 is 2^10 * 2^10 mega,~ 1 million, 1 megabit, or 1 Mb 2^30 is 1 gigabit or ~ 1 billion bits 2^40 is 1 terabit or ~ 1 trillion bits

39 We can do this with bytes too 8 bits is 1 byte 2^10 bytes is 1024 bytes is 1 kilobyte (KB) 2^20 is 1024 * 2^10 bytes is 1 megabyte or 1 MB 2^30 bytes is 1 gigabyte or 1 BG 2^40 bytes is 1 terabyte or 1 TB

40  Binary for numbers is base 2  1 1 0 1 (base 2) is 1 times 2^3 … 8 (base 10) 1 times 2^2 … 4 0 times 2^1 … 0 1 times 2^0 … 1 13 (base 10) add these together

41  Here is a Web page with a JavaScript programWeb page  Here is the program source code function simpleFunc( ) { //put your program text below the dashed line //---------------------------------------------- alert("Hello from your first program !"); //---------------------------------------------- //put your program text above the dashed line }

42  You know what a model is  Using the von neumann computer model, you know about the insides of the computer you will program  You have run your first program  You know that computers store information (data, programs) internally in binary form (base 2)

43  Review math: base 2 and powers of 2  Read intro, chap. 1 in text  Download first program HTML doc to your PC and make sure you can ◦ edit it, esp. … ◦ make the browser browse it ◦ run the program

44


Download ppt "David Stotts Computer Science Department UNC Chapel Hill."

Similar presentations


Ads by Google