1 chapter 1 introduction. 2 objective computer science 可以把它當成是一門與電腦相...
Post on 20-Dec-2015
250 views
TRANSCRIPT
1
Chapter 1 Introduction
2
Objective
Computer Science 可以把它當成是一門與電腦相關的學科。為了要瞭解電腦的運作,我們把電腦想像成一個黑盒子,想要嘗試去瞭解電腦共通的特徵,例如電腦中一定要有那一些元件,分別負責甚麼功能,好像在做模型一樣。
這個電腦共通的模型,稱為 von Neumann model。這個章節我們就要先瞭解甚麼是 von Neumann model,並在後面的章節中一一再詳述所有的概念。
3
Outlines
The Computer as a Black Box Von Neumann Model Computer Hardware Data Computer Software History Key Terms Summary Practice Set Homework
4
Section 1.1The Computer as a Black Box
5
Computer as a Black box
Computer science as “issues related to the computer”
Look a computer as a black box How to define the job performed by this box? Two common computer model:
• Data processor• Programmable data processor
6
Data Processor Model
ComputerInput Data
Output Data
A computer acts as a black box • Accept input data• Process the data• Create output data
Disadvantage: • It is too general.• It does not specify the type of processing.
7
Programmable Data Processor Model
ComputerInput Data
Output Data
Program
A program is a set of instructions that tells the computer what to do with data.
A program is a set of instructions written in a computer language.
8
Example: C Language
#include <iostream>using namespace std;main( ) { int a=0,b=0,c=0 ; /* variable declaration */ cin >> a; /* read input */ cin >> b; c=a+b; /* variable operation */ cout << c ; /* output to screen */}
9
Same Program, Different Data
ComputerInput Data
14, 6, 8, 12
Output Data
6, 8, 12, 14
Sort Program
ComputerInput Data
3, 12, 8, 22
Output Data
3, 8, 12, 22
Sort Program
10
Same Data, Different Program
ComputerInput Data
3, 12, 8, 22
Output Data
3, 8, 12, 22
Sort Program
ComputerInput Data
3, 12, 8, 22
Output Data
45
Add Program
ComputerInput Data
3, 12, 8, 22
Output Data
3
SmallestProgram
11
Same Program, Same Data
ComputerInput Data
3, 12, 8, 22
Output Data
3, 8, 12, 22
Sort Program
12
Comparison of Two Models
Data processor• It represents a specific-purpose computer.• Sometime, we call it as processor.
Programmable data processor• Computers are general-purpose machines.
In Section 1.2, we will try to use von Neumann model to find:
How does a general-purpose computer work?
13
Section 1.2Von Neumann Model
14
Von Neumann Model
Every computer today is based on the von Neumann model.• John von Neumann
Basic on three ideas:• Four subsystems• Stored program concept• Sequential execution of instructions
15
Four Subsystems (1/2)
Memory: storage area Arithmetic Logic Unit (ALU): perform
arithmetic and logic operations Input/Output (I/O): accept input data and
send output data Control Unit: control the operations of the
memory, ALU and I/O.
16
Four Subsystems (2/2)
Input Data
Output Data
Program
Control Unit
Arithmetic Logic Unit
Memory
Input/Output
17
Stored Program Concept
Both the data and programs stored in memory.
Program and data should have the same format because they are stored in the same memory.
Program
Data
memory
18
Sequential Execution of Instructions
A program is made of a finite number of instructions.
The instructions are executed one after another.
The control unit • Fetches one instruction from memory • Interpret it (decode) • Execute it
Fetch
Execu
te
Decode
Instruction Cycle
19
Real Computer
Von Neumann model is just a model! How to realize a computer? There are 3 components in a computer:
• Computer Hardware in Section 1.3• Computer Software (Program) in Section 1.5• Data in Section 1.4
20
Section 1.3Computer Hardware
21
Computer Hardware
A physical computer must contains all components in von Neumann model.
We will discuss computer hardware in Chapter 5.
22
Computer Network
How to communicate 2 computers? See Chapter 6
23
Section 1.4Data
24
Storing Data (1/2)
How to store data in memory? Computer processing is performed by electronic
devices, which are switches with only two possible states: on and off.• If the electrical signal is in a storage device
(presence), it is assigned a value of 1 and it is on. • If the electrical signal is not in a storage device
(absence), it is assigned a value of 0 and it is off. • Two states (binary: 0/1)
Storage is a binary world!
25
Storing Data (2/2)
How to store different types of data as a binary pattern? • Ex: 2 v.s. 00000010 in 2’ complement• Ex: 4 v.s. 00000100 in 2’ complement• Ex: 100 v.s. 01100100 in 2’ complement
How data are manipulated as a binary pattern?• Ex: Binary addition / subtraction / logical operation• Ex: 2+2=4 v.s. 010+010=100
Answers are in Chapters 2,3,4.
26
Data Organization
Data outside a computer can take many forms.
Data is stored in binary form inside a computer.• Data are organized into small units. • Small units organized into larger units.
Answers are in Chapters 11-14: data structure, abstract data structure, file structure, database.
27
Section 1.5Computer Software
28
Computer System
29
Programming
The main feature of the von Neumann model is the concept of the stored program.
Two aspects of programming:• A sequence of instructions• Programs must be stored (into the memory when
they run!)
See Chapter 9
30
Program and Data in Memory
Memory is used to hold data and program.
Program
Data
Program
main memory
31
Program Made in Instructions
cin >> A; cin >> B; C=A+B; cout << C;
Program to find the summation of two integer
Why a program must be made of instruction? Answer is reusability.
• Basic instructions are provided by computer hardware.
• Programmers combine these instructions to perform thousand of tasks.
32
Algorithm
How to write a program by a programmer? 1. Solve the problem in a step-by-step manner.
2. Try to find the appropriate instructions and combine them as a program
The step-by-step solution is called an algorithm. (See Chapter 8)
1. Input first data item into memory. (call it as A) 2. Input second data item B into memory. (call it as B) 3. Add the two together and store the result in memory. 4. Output the result. Algorithm to find the summation of two integer
33
Computer Languages
Machine language: 0 and 1 only! Computer language: the idea of using
symbols to represent binary patterns• Ex: C language, Java
Compare to Natural language:• Computer language has more limited number of
symbols, and a limited number of words.• Ex: Summary/Addition v.s. +• Ex: read from standard input v.s. cin >>• Ex: print out to standard output v.s. cout <<
34
Software Engineering
Software engineering is the design and writing of structured programs.
The program must follow strict principles and rules.• Ex: True is 1, False is 0.• Ex: Analysis → Design → Prototype → Test → A
large scale product• Ex: Full documents
See Chapter 10.
35
System Development
Define SystemSpecification
Develop Real
System
Create Prototype
Use Prototype
Modify Prototype
User OK?
User suggestion
yes
no
36
Operating System (OS)
There are a series of instructions (tasks) common to all programs. It is not necessary to write the same tasks in all programs.• Ex: receive data from keyboard
The operating system originally worked as a manager to facilitate access of the computer components for a program.• Ex: Windows, Unix, FreeBSD
See Chapter 7.
37
Advanced Topics
Chapter 15: data compression Chapter 16: security Chapter 17: theory of computation
38
Data Compression
MPEG framesRun-Length
39
Security
Public Key Encryption
Secret Key Encryption
40
Theory of Computation
Turing Machine
41
Section 1.6History
42
The History of Computing and Computer
There are three periods: Mechanical machines (before 1930) Birth of electronic computer (1930-1950)
• Early electronic computers• Computers based on von Neumann model
Computer generations (1950-present)• First to Fifth generations
43
The Advances of Hardware in Computer
Mechanical (1896) Mechanical + Electrical (1930) Vacuum Tube (1944) Transistors (1959) Integrated Circuit (IC) (1967) Storages (CD-ROM, DVD)
vacuum tube
transistorIC
44
Mechanical Machines
Abacus Based on the technology of gears
• Blaise Pascal (1623-1662) • Gottfriedn Wilhelm Lebniz (1646-1716)• Joseph-Marie Jacquard’s loom (1801) • Charles Babbage (1792-1871)
Difference EngineAnalytic Engine: all components in von Neumann modelAugustra Ada Byron: First Programmer in the world
• Herman Hollerith (1860-1929)Automatic read/write data from/to punched cards
45
Pascal’s Machine
46
Jacquard Loom
The first machine used the idea of store and programming!
47
Babbage’s Machines
Analytical Engine
Difference Engle
48
Birth of Electronic Computers (1/2)
Electronic mechanical machine• Howard Aiken & IBM’s Maker I (1930s)
Digital computer with vacuum tube• John Atanasoff & Clifford Berry’s Atanasoff-Berry
Machine: ABC, first special-purpose electrical computer (1939)
• 1946, ENIAC, first general-purpose electronic computer
• Konrad Zuse’s Z1 (about 1939)• Alan Turing’s COLOSSOS
49
Birth of Electronic Computers (2/2)
Above machines:• Memory only for storing data• Programmed externally by using wires or switch
The first computer based on von Neumann model is Pennsylvania’s EDVAC (1950).
At the same time, Cambridge’s EDSAC is created by Maurice Wilkes.
After 1950, almost computers are following the von Neumann model.
50
Mark I
Begin at 1937, Finished at 1944 Leader: Howard Aiken
• Work with IBM• Idea come from Babbage
51
The Mark I Computer, completed in 1940 at Harvard University
52
ENIAC
“ Where... the ENIAC is equipped with 18,000 vacuum tubes and weighs 30 tons, computers in the future may have 1,000 vacuum tubes and perhaps weigh just 1-1/2 tons.” Popular Mechanics, March 1949, p.258
53
Computer Generations (1950-Present)
First Generation (roughly 1950-1959)• Commercial computers, professionals, Mainframe
Second Generation (roughly 1959-1965)• Transistors, FORTRAN, COBOL
Third Generation (roughly 1965-1975) • Integrated circuit (IC), Minicomputer, software packet
Forth Generation (roughly 1975-1985) • VLSI, Microcomputer, computer network
Fifth Generation (started in 1985)• Laptop, storage, multimedia, virtual reality
54
Technology Trends
ProcessingIntegration
• Single-chip systems
Communication• Optical and wireless
Storage density - CDROM, DVD etc
55
Market Trend - “Consumer Friendly”
Visual Communication• 3D sounds and images
Internet Explosion• Information and communication
Information Appliances• Personal organizers• Mobile phones• Wearable computers
56
A Growing Industry
In 2008, there are 109 desktop computers or notebooks in the world.• The growth rate is about 12%.• In 2014, there are 2×109 PC in the world.
科技產業資訊室• http://cdnet.stpi.org.tw/techroom.htm
57
Section 1.7Key Terms
58
Key Terms (1/2)
How many terms can you describe?• Algorithm• Arithmetic logic unit (ALU)• Black box• Computer language• Computer Science• Control unit• Data processor• Input data• Instruction• Integrated circuit
59
Key Terms (2/2)
How many terms can you describe?• Memory• Microcomputer• Operating system• Output data• Program• Programmable data processor• Software• Software engineering• Von Neumann model
60
Section 1.8Summary
61
Summary (1/3)
Computer science means issues related to a computer.
A computer is a programmable data processor that accepts input data and programs and outputs data.
A program is a set of instructions executed sequentially that tells the computer what to do with data.
Every computer today is based on the von Neumann model.
62
Summary (2/3)
The von Neumann model specifies • A memory subsystem• An arithmetic logic unit subsystem• A control unit subsystem• An input subsystem• An output subsystem
63
Summary (3/3)
Data and programs are stored in computer memory.
A step-by-step solution to a problem is called an algorithm.
A program is written in a computer language. Software engineering is the design and
writing of programs in a structured form.
64
Practice Set
Review Questions Multiple-Choice Questions Exercises
65
Homework
Review Questions: 5,6,7,8,9,11 Multiple-Choice Questions: 12-26 Exercises: 32, 33