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

Post on 01-Jan-2016

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

COMS 161Introduction to Computing

Title: Computing Basics

Date: September 10, 2004

Lecture Number: 8

2

Announcements

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

3

Review

• Number Systems– Binary Coded Decimal (BCD)

• ASCII

4

Outline

• Hexadecimal Numbers

• Digitization

• Computer System Basics

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

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

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

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

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

10

Digitization

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

• Discrete• Analog

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

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

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

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

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

16

• Images are digitized using a two step process

• Sampling the continuous tone image

• Quantizing the samples

Digitizing Images

17

Sample image by pixel resolution

Spatial Sampling

Sample two-dimensional space

Sampling Images

18

All gray values in each sample are averaged

Quantizing Images

19

Different amount of sampling

Quantizing Images

20

Different amount of sampling

Quantizing Images

21

Different amount of sampling

Quantizing Images

22

Computer Systems

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

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

– Shoes??

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

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

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

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

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

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!!!

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

30

Computer Systems

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

Chopper!!

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

+

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

33

• Indirection

Computer Systems

37

1215

23423

45135

5

+

val1

val2

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

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

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

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

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

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

39Main memory

BusCPU

Computer Systems

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

41

• Bidirectional bus– Data flows to and from memory

• Into and out of memory

Computer Systems

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

43

• Peripheral devices– Components added to the basic computer

system

– Increase the systems functionality

– Secondary memory

– Input/output devices

Computer Systems

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

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”);

}

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

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

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

49

Windows Example

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

51

Applications

• Are restricted to a specific problem domain

• Have a user interface based on some intuitive metaphor

• Use conducted in sessions

top related