Introduction to Computers

Department of Computer and Information Science,
School of Science, IUPUI
CSCI 230
Computer Architecture
Dale Roberts, Lecturer
Computer Science, IUPUI
E-mail: [email protected]
What is a Computer?
Computer
Device capable of performing computations and making
logical decisions
Computers process data under the control of sets of
instructions called computer programs
Personal computers: economical enough for individual
Distributed computing: computing distributed over
networks
Client/server computing: sharing of information across
computer networks between file servers and clients
(personal computers)
Dale Roberts
What is a Computer? (cont.)
Computer Hardware
Various devices comprising a computer:
Keyboard, screen, mouse, disks, memory, CD-ROM, and
processing units
Hardware Trends: every year or two the following
approximately double (Moore’s Law):
Amount of memory in which to execute programs
Amount of secondary storage (such as disk storage)
Used to hold programs and data over the longer term
Processor speeds
User
High-level
Language
Application
Software
Assembly
Language
The speeds at which computers execute their programs
Computer Software
Computer Programs that run on a computer, including
Operation System (OS)
Application Software
Computer Language
OS
Firmware
Machine
Code
Hardware
Moore's Law
Defined by Dr. Gordon Moore during the
sixties.
Predicts an exponential increase in
component density over time, with a
doubling time of 18 months.
Applicable to microprocessors, DRAMs ,
DSPs and other microelectronics.
Monotonic increase in density observed
since the 1960s.
Moore’s Law - Density
Moore's Law and Performance
The performance of computers is
determined by architecture and clock
speed.
Clock speed doubles over a 3 year period
due to the scaling laws on chip.
Processors using identical or similar
architectures gain performance directly as
a function of Moore's Law.
Improvements in internal architecture can
yield better gains than predicted by
Moore's Law.
Moore’s Law - Clock Speed
What is a Computer? (cont.)
Internet
The Internet enables
Quick and easy communication via e-mail
International networking of computers
Packet switching
The transfer of digital data via small packets
Allows multiple users to send and receive data simultaneously
No centralized control
If one part of the Internet fails, other parts can still operate
Bandwidth
Information carrying capacity of communications lines
Ex: Internet T2 at IUPUI
World Wide Web
Locate and view multimedia-based documents on almost any subject
Makes information instantly and conveniently accessible worldwide
Possible for individuals and small businesses to get worldwide exposure
Changing the way business is done
Computer Organization
A Typical Von-Neumann Architecture
CPU
Control Circuit
(ex: PC: Program Counter)
Memory
ALU
Example:
1.
2.
3.
4.
5.
6.
Input unit
Output unit
Memory unit
Arithmetic and logic unit (ALU)
Central processing unit (CPU)
Secondary storage unit
I/O
Computer Organization (cont.)
Six logical units in every computer:
1.
Input unit
Obtains information from input devices (keyboard, mouse)
2.
Output unit
Outputs information (to screen, to printer, to control other devices)
3.
Memory unit
Rapid access, low capacity, stores input information
ROM (Read Only Memory): CMOS, EPROM …
RAM (Random Access Memory): SRAM, DRAM, SIMM, DIMM …
4.
Arithmetic and logic unit (ALU) – part of CPU
Performs arithmetic calculations (addition, subtraction...) and logic
decisions
5.
Control unit (CU) - part of CPU
Supervises and coordinates the other sections of the computer
6.
Secondary storage unit
Cheap, long-term, high-capacity storage
Stores inactive programs
Computer Organization (cont.)
Central Processing Unit (CPU),
“brain” of a computer, consisting of
Arithmetic and logic unit (ALU): performs arithmetic calculations (addition,
subtraction...) and logic decisions (>, <, =, ...)
Control Unit (CU): decodes each machine instruction and sends signal to other
components for carrying out the instruction.
An integrated circuit (IC) that is a full central processing unit is called a
microprocessor (p); a CPU’s current instruction and data values are stored
temporally inside the CPU in special high-speed memory location called
registers.
CPU speed: ? MHz (M: Mega = 106, Hz=1/sec);
Memory
A large collection of circuits, each capable of storing bit
Cells (words): manageable units; typical size is 8 bits (1 byte), some
machines are 16 bits (2 bytes) and some are 32 bits or 64 bits
Byte (8 bits), KB (kilobyte, 103  210 bytes), MB (Megabyte, 106  220
bytes), GB (Gigabyte, 109  230 bytes). Note: k ≠ K because 1000 ≠ 1024.
Computer Organization (cont.)
Computer memory is comparable to a collection of
numbered mailboxes. To identify individual cells in a
machine’s main memory, each cell is assigned a unique
name, called its address
ASCII
H
e
l
l
o
,
Data
01001000
Address
0000 0101
01100101 01101100 01101100 01101111 00101110
0000 0110
0000 0111
0000 1000
0001 0001
...
...
0001 0010
Address Bus
Data Bus
The organization of byte-size memory cell
Most Significant Bit (MSB)
High-order end
Least Significant Bit (LSB)
0 0 0 0 0 1 0 1
Low-order end
Operation System (OS)
Responsibilities:
Command-line
Interface
Communicating with the computer user
UNIX
Managing allocation of memory, of processor MS_DOS
VMS
time, and of other resources for various tasks
I/O handling: BIOS vs DOS services (Interrupts)
Read/Write data from secondary storage
Graphical User
Interface (GUI)
MacOS
Windows
X Windows
(linux and solaris)
Evolution of Operating Systems
Batch processing: do only one job or task at a time
Operating systems: manage transitions between jobs and
Increase throughput (amount of work computers process)
Multiprogramming: Computer resources are shared by many
jobs or tasks
Timesharing: Technique used to implement multiprogramming
where the computer runs a small portion of one user’s job
then moves on to service the next user
Application Software
Developed to assist a computer user in
accomplishing special tasks
ex: word processing applications: MS-word or
Word-perfect
ex: Spreadsheet applications: Lotus1-2-3, Excel
ex: Database: Oracle, MS-Access
Software Development Life Cycle (SDLC)
Problem: specify the problem requirements
Analysis: analyze the problem
Design: design the algorithm to solve the problem
Implementation: Implement the algorithm
Testing: test and verify the completed program
Maintenance: maintain and update the program
Programming Languages
1. Machine languages (machine dependent)
Native tongue of a particular kind of computer. Each instruction is a binary
string. The code is used to indicate the operations to be performed and
the memory cells to be addressed. This form is easiest form of computers
to understand, but is most difficult for a person to understand.
Strings of numbers giving machine specific instructions
Example: +1300042774
+1400593419
+1200274027
2. Assembly languages (machine dependent)
English-like abbreviations representing elementary computer operations
(translated via assemblers)
Again specific to only one type of computer. Uses descriptive names for
operations and data, e.g. , “LOAD value”, “ADD delta”, “STORE value”.
Assemblers will translate these to machine languages. Intermediate level.
Somewhat descriptive, but basically following the machine instructions.
Example: LOAD
BASEPAY
ADD
STORE
OVERPAY
GROSSPAY
Programming Languages (cont.)
3. High-level languages (machine independent)
Codes similar to everyday English
High-level languages: Write program instructions called statement
that resemble a limited version of English. e.g., the statement
“value = value + delta”. Portable, meaning it can be used on
different types of computers without modifications. Compilers
translate them to machine languages. Examples are FORTRAN,
PASCAL, COBOL, C, C++, BASIC etc.
Use mathematical notations (translated via compilers)
Example:
grossPay = basePay + overTimePay
a
Before b
Example:
Statement:
a= a + b
a
After
b
10
7
17
7
Programming Languages (cont.)
Structured programming
Disciplined approach to writing programs
Clear, easy to test and debug and easy to modify
Multitasking
Specifying that many
activities run in parallel (still timesliced)
Language
FORTRAN
COBOL
Lisp
C
Prolog
Ada
Smalltalk
C++
JAVA
Application Area
Scientific programming
Business data Processing
Artificial Intelligence (AI)
System Programming
AI
Real-time distributed systems
GUI, OOP
Supports object & OOP
SupportsWeb programming
Origin of Name
Formula Translation
Common Business-Oriented Language
List Processing
Predecessor B
Logic Programming
Ada Augusta Byron & Charles Babbage
Objects “talk” via message
C (++ is the increment operator)
Originally named “Oak”
Semantic Gap
A “semantic gap” exists between the amount of
information conveyed in assembly language v high level
languages. Consider the following C single statement:
x = x + 3;
This single statement may require many assembly
language statements (operations):
Load memory location 24 into accumulator
Add a constant 3 to the accumulator
Store accumulator in memory location 24
The number of executable statement expands greatly
during the translation process from a high level
language into assembly language.
C Programming Language
C
High-level general-purpose language developed in 1972 at AT&T Bell
Lab. By Dennis Ritchie from two previous programming BCPL and B
Originally developed to write the UNIX operating system
Hardware independent (portable)
By late 1970's C had evolved to "Traditional C"
Today, virtually all new operating systems are written in C or C++.
The current standard in C is ANSI C.
C++ is a more advanced version of C, incorporating among other
things, the object-oriented constructs
Standardization
Many slight variations of C existed, and were incompatible
Committee formed to create a "unambiguous, machine-independent" definition
Standard created in 1989, updated in 1999
C has become a popular language industry due its power and flexibility
The C Standard Library
C programs consist of pieces/modules called functions
A programmer can create his own functions
Advantage: the programmer knows exactly how it works
Disadvantage: time consuming
Programmers will often use the C library functions
Use these as building blocks
Avoid re-inventing the wheel
If a pre-made function exists, generally best to use it rather than write your
own
Library functions carefully written, efficient, and portable
The Key Software Trend: Objects in C++ and JAVA
Reusable software components that model items in the real world
Meaningful software units: ex: Date objects, time objects, audio objects, video
objects, file objects, record objects…any noun can be represented as an object
More understandable, better organized, and easier to maintain than
procedural programming
Favor modularity
The C Standard Library
#include <stdio.h>
main()
{
int i;
for (i = 0; i ++; i < 10)
{
printf ("Hello World!\n");
}
}
A Typical C Program Development Environment
• Phases of C Programs:
Editor
Disk
Preprocessor
Disk
Compiler
Disk
Linker
Disk
1. Program is created in the
editor and stored on disk
2. Preprocessor program
processes the code
3. Compiler creates object
code and stores it on disk.
4. Linker links the object
code with the libraries
1. Edit
2. Preprocess
3. Compile
4. Link
Primary Memory
5. Load
Loader
5. Loader puts program
in memory.
Disk
Primary Memory
CPU
6. CPU takes each instruction
and executes it, possibly
storing new data values as
the program executes
6. Execute
A Typical C Program Development Environment (cont.)
• Procedure to Prepare a C Program for Execution
Enter the program code and
save as a source (*.c) file using
Word Processor (editor)
Source (.c)
file on disk
(Format: text)
Compiler attempts to
translate the program
into machine code
Failure
Revised
source file
Correct
syntax
errors
List of errors
Success
New object
(*.obj) files
(Format: binary)
The linker links the
new object file with
other object files
Other object
(*.obj) files
Input data
Executable
(*.exe, *.out) file
(Format: binary)
The loader places the
executable file into
memory
Executable
program in
memory
Welcome to
CSCI230
Results
Constructs in C Language
Type Declarations: ex: int, float,…
I/O: ex: printf(), scanf()
Arithmetic and Logical Operations: ex: +,-,*,/,%,>,<,==,…
Arrays, Pointers, Structures, Unions, …
Functions
Arguments & return values
Recursion
Control Mechanisms: ex: if, else, while, for,…
Characters & Strings: ex: strcat(), strcpy(), …
File Processing: ex: fopen(), fclose(), …
Pre-processor: ex: #define …
Misc.
bit operations, ...
Acknowledgements
Moore’s Law: Kopp, Carlo. Monash University.
Melbourne, Australia. 2000.