1 coms 161 introduction to computing title: computing basics date: september 10, 2004 lecture...

51
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

Upload: lesley-cunningham

Post on 01-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

1

COMS 161Introduction to Computing

Title: Computing Basics

Date: September 10, 2004

Lecture Number: 8

Page 2: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

2

Announcements

• Research paper proposals due– 9/17/04, next friday

Page 3: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

3

Review

• Number Systems– Binary Coded Decimal (BCD)

• ASCII

Page 4: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

4

Outline

• Hexadecimal Numbers

• Digitization

• Computer System Basics

Page 5: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

5

Binary Number System

• Precision– The number of bits used to represent an item

• Letter: precision of 8 bits• Integer (whole number): precision of 32 or 64 bits

– Letters and integer numbers are very precise• Known bit pattern corresponds to a letter or number

– Always finite• Computers have finite precision

– Presents some limitations

Page 6: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

6

Hexadecimal Number System

• Sometimes called hex– Positional,base-16 system

– Each digit is multiplied by a power of 16

– Sixteen unique symbols (digits)• 0, 1, 2, …, 15

• Symbol a or A for 10• Symbol b or B for 11 Symbol e or E for 14• Symbol c or C for 12 Symbol f or F for 15• Symbol d or D for 13

Page 7: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

7

Hexadecimal Number System

• A hex number can represent 16 different items– Represent one hex number with 4-bits

– Easy to convert between binary and hex representations• Group bits by 4’s from the right end• Substitute the hex symbol for each nibble

– 9010 = 0101 10102 = 5A16

» Is the base 16 really needed?

– 6610 = 0100 00102 = 4216

Page 8: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

8

Hexadecimal Number System

• Use the backwards conversion to convert hex to binary– One hex digit represents 4-bits

– Substitute the binary nibble• Always start at the right end• Add zeros to the left end as necessary to fill in 4

bits

Page 9: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

9

Hexadecimal Number System

HEX DEC BIN

0 0 0000

1 1 0001

2 2 0010

3 3 0011

4 4 0100

5 5 0101

6 6 0110

7 7 0111

8 8 1000

9 9 1001

A 10 1010

B 11 1011

C 12 1100

D 13 1101

E 14 1110

F 15 1111

Page 10: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

10

Digitization

• The process of converting information into a binary form– Two classes of information to digitize

• Discrete• Analog

Page 11: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

11

Digitization

• Discrete forms are easier to digitize– Discrete information is unambiguous

• Text and numbers are discrete values

– Conversion of discrete to digital• Come up with a mapping

– As we did with the letters– ASCII encoding– Two’s complement

Page 12: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

12

Binary Coded Decimal

• Integers (whole numbers)– One mapping is to use each digits binary

equivalent• Binary Coded Decimal (BCD)

– 010 = 00002

– 110 = 00012

– …

– 910 = 10012

• Need a minimum of 4 bits to represent 10 different values

– Some 4 bit quantities are wasted

Page 13: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

13

Binary Coded Decimal

• String of decimal digits– Each decimal digit is represented by 4 bits– The number of bits needed to represent different

numbers vary– Performing arithmetic is complicated

• Numbers must be converted into another form to computer the correct answer

• BCD is a possible mapping between (all) integers and a binary representation

Page 14: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

14

Digitizing Analog Information

• Two steps– Sampling the information

• Select discrete samples that represents the information

– Quantizing the samples• Discrete samples are measured• Encoded into a binary representation

Page 15: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

15

Digitizing Analog Information

• Sampling– In time or space (picture)

• Quantizing– Approximating the measured value

• Placing all continuous values within a range into a bin

• Binning

Page 16: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

16

• Images are digitized using a two step process

• Sampling the continuous tone image

• Quantizing the samples

Digitizing Images

Page 17: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

17

Sample image by pixel resolution

Spatial Sampling

Sample two-dimensional space

Sampling Images

Page 18: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

18

All gray values in each sample are averaged

Quantizing Images

Page 19: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

19

Different amount of sampling

Quantizing Images

Page 20: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

20

Different amount of sampling

Quantizing Images

Page 21: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

21

Different amount of sampling

Quantizing Images

Page 22: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

22

Computer Systems

• A dime a dozen!!– They are everywhere and their uses continue

to expand• Microwaves• Clocks• Cars• Watches• What’s next

– Shoes??

Page 23: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

23

Computer System

• Electronic digital data processing machines– Data: symbolic representation of information

– Digital: numeric codes

– Computers are discrete state machines• Finite number of states

– All are distinct and different

• Always in a state

Page 24: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

24

Computer System

• Process– Set of actions

– Traversing certain states• Sequence of distinct states

– Fast to go from one state to another• Billionths of a second

– So fast, a process appears continuous• As do light bulbs• Your TV screen

Page 25: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

25

Computer System

• Mechanical computers

• Mechanical and electrical

• Electromechanical

• Electronic– Fastest, but still performs simple steps

– One of the great illusion of the computer: • Lots of simple steps performed quickly enough

make the computer appear complicated

Page 26: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

26

Computer Systems

• State transitions are simple– Baby steps

– States are independent• Does not matter on state before or after

• Instructions cause state transitions– Going from one state to the next

– Must be precise and unambiguous• Causing the desired state transition

– Instructions are executed

Page 27: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

27

DWIM

• The notorious instruction– Prof P’s grand challenge

• $1000.00 reward

– Make a machine the executes the DWIM instruction• Do• What• I• Mean

Page 28: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

28

Computer Systems

• Unlike students (and my daughters)– Computers do what they are told to do

• Nothing more, nothing less

• Computer Programs (applications)– Consist of a sequence of instructions

– Running a program• Executing one instruction after another

– This is the primary job of the computer!!!

Page 29: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

29

Computer Systems

• Think of the computer as a dogg!– Here boy, here boy, …

– Fetch-decode-execute cycle

– No good boy or treats are necessary!!

Fetch the next instructionDecode the instructionExecute the instructionRepeat

Page 30: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

30

Computer Systems

• The fetch-execute cycle– This is not your fathers Orange County

Chopper!!

Page 31: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

31

Computer Systems

• Data instructions– Instructions that perform an operation on

specified data• add 3, 5

• Instruction refers to the values to be added directly

– Instruction has direct access to the values to be added

3

5

+

Page 32: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

32

Computer Systems

• Indirection– Advantageous to refer to data indirectly

• Makes programs more general

– Instruction tells where the data is, not what the data is• Other values can be stored and processed

– add val1, val2• val1 and val2 refer to locations that contain the

values to add

Page 33: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

33

• Indirection

Computer Systems

37

1215

23423

45135

5

+

val1

val2

val1 and val2 could refer to any other place which contains other values

Page 34: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

34

• Instructions that refer to data– Put the values in special places

• Get the values from where they are• Save them in a place where the adder looks for

its input

– Execute the add instruction

– Place the result someplace

Computer Systems

Page 35: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

35

Computer Systems

• Slight variant of the add instruction

• add val1, val2, val3– Fetch the value referred to by val1

• Read the memory at the location of val1• Put the value on one of the adder inputs• Read the memory at the location of val2• Put the value on the other adder inputs

– Execute the add

– Put result in memory at location val3

Page 36: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

36

• Seemingly simple instruction like add– Require several simpler steps to execute

• As complex as computers seem, they still do simple things– Moving data from one place to another– Simple arithmetic operations

• Illusion of complexity– Perpetuated by the speed of simple

operations

Computer Systems

Page 37: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

37

• Composed of two major items– Hardware

• Electronic devices that perform specific tasks• Two basic groups

– Processing unit» The heart of the computer

– Peripherals

– Software• Programs the hardware executes

Computer Systems

Page 38: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

38

• Processing unit– Central processing unit (CPU)

• Controls the instruction-execution cycle

– Main memory• Stores both data and instructions

– Bus• Connection between main memory and the

CPU• Data and address bus

Computer Systems

Page 39: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

39Main memory

BusCPU

Computer Systems

Page 40: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

40

• Main memory– Composed of individual memory cells

– Cells are grouped into words

– Words are accessed via a unique address

Memory Control Unit

Data Bus

Address Bus

0x35500x35540x35580x355c0x35600x35640x35680x356c

unique memory address

Computer Systems

Page 41: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

41

• Bidirectional bus– Data flows to and from memory

• Into and out of memory

Computer Systems

Page 42: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

42

• Read memory (read from memory)– Memory controller access word at specified

address for a read operation

– Data in the memory is put on the data bus

• Write memory (write to memory)– Data to write into memory is on the data bus

– Memory controller access word at specified address for a write operation

Computer Systems

Page 43: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

43

• Peripheral devices– Components added to the basic computer

system

– Increase the systems functionality

– Secondary memory

– Input/output devices

Computer Systems

Page 44: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

44

Software

• Programs– Written using programming languages

(symbolic codes for expressing computer instructions)

• Programs ≠ processes

• Conditional processing– The ability to alternative actions based on

the recognition of changing conditions

Page 45: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

45

Conditional Processing

• Program execution depends on certain conditions

If (ProfP) {Print(“A one of a kind”);Print(“Y’all gonna miss me”);

} else {Print(“We are the happy idiots”);Print(“The mediocre”);Print(“Those who fear excellence”);

}

Page 46: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

46

Operating Systems

An operating system is a collection of resident programs that manage the computer’s resources, supervise the execution of processes, and provides useful services and security.

• Continuous control of system• Supervises processes• Creates useful abstractions for users• Defines computing experience

Page 47: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

47

Managing Files

• A file is a sequence of items treated as a unit and identified with a unique name

• filenames are composed of– identifier + ‘ .’ + extension

• identifier (Windows) = up to 255 symbols excluding special characters

• extension (Windows) = 1 - 4 characters that are used to classify file

Page 48: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

48

Hierarchical File System

• tree--special type of graph

• nodes, edges (links)• parent(s)• child(ren)• ancestor(s)• descendant(s)

• directory structure--series of levels based on a tree

• files, folders• path--list of all

ancestors of a file/folder from root

• pathname--conventional listing of path

Page 49: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

49

Windows Example

Page 50: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

50

User Interface

• TEXT-BASED– Command line interpreters

• Terse, but powerful• Steeper learning curves• Burden of communication on user

• GRAPHIC USER INTERFACES (GUI)– Manipulate visual elements– User-friendly– More tedious

Page 51: 1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 10, 2004 Lecture Number: 8

51

Applications

• Are restricted to a specific problem domain

• Have a user interface based on some intuitive metaphor

• Use conducted in sessions