Comprehensive Hardware Notes

Download Report

Transcript Comprehensive Hardware Notes

Input, Output and Hardware
Farahnaz Wick
Computer Architecture
• Conceptual design or the fundamental
operational structure of a computer system
– Blueprint
– Example: Architect
Von Neumann Architecture
Input
device
Central Processing Unit
Output
device
Control Unit
Arithmetic/Logic Unit
Auxiliary
storage
device
Memory Unit
Five components:
• Memory unit holds both data and instructions
• ALU is capable of performing arithmetic and logic operations on data
• Input unit moves data from user to computer
• Output unit displays or prints results
• Control unit acts as manager of different components
Fetch Execute Cycle
• Store, retrieve, process data
– Remember: Von Neumann architecture means data and instructions can be stored in
main memory
• Processing cycle has four steps:
1.
2.
3.
4.
Program Counter
Fetch the next instruction
Decode the instruction
Get data if needed
Execute the instruction
Instruction Register
ALU
Control Unit
(3) Get data
(2) Decode Instruction
Fetch Cycle
Registers
(1) Fetch Instruction
Execution Cycle
(4) Execute Instruction
Main Memory
Processors
• Clock speed
• Number of bits the processor can deal with per clock cycle
• Number of processors: Higher the number of processors the better
the performance
• Cores: Number of CPUs on the motherboard, efficiency increases,
sharing of tasks
– Could be expensive, communication between cores, multiple heat sinks on
mother board
– Depends on applications (PCs are fine but for small devices like phones cores
are better than multiple processors)
What is the clock rate?
• The clock rate is number of bits processed per second
– Speed at which the processor executes instructions
• Every computer has its own internal clock that
regulates this rate
– It is actually a square signal
– Its period/frequency depends on the maximum time taken by
the electrical signals to move to various circuits in the CPU
– Determined by the manufacturer
– What is potential bottleneck for clock speed?
Parallel processing systems
Control
Processor
N
Processor
1
Processor
2
Processor
4
Processor
5
Data Set N
Data Set 1
Data Set 2
Data Set 4
Data Set 3
Synchronous processing: Multiple processors apply the same program to
multiple data sets
Why would you want to do this?
Pipelining processing
Result 1
Processor
1
Result 2
Processor
2
Result 3
Processor
3
Processor
N
Pipeline processing: Multiple processors arranged in tandem where each
contributes one part of an overall computation
Why would you want to do this?
Multi-core processors
Shared Memory
Processor
1
Processor
2
Local
Memory
Local
Memory
Processor
3
Local
Memory
• Work independently
• Communication and co-ordination
• Extra resources: Shared and local memory
Multi-core processors
Advantages:
• Performance! better use of clock rate
• Power efficient
Disadvantages:
• Chip design
• Additional resources/efficiency tradeoff
• Sharing the same system bus and memory bandwidth limits
the real-world performance advantage
Memory
• Fast access memory (main memory, registers) and slow access
memory (secondary storage devices -hard disks, floppy, cds etc)
• Fast Memory: temporary state devices
• Secondary storage: permanent
• Collection of cells that can store, preserve and recall data
– Physical address accessed by CPU
Memory
• Addressability: Number of bits stored in each
addressable location in memory
– Byte addressable: Each cell stores 8 bits
• If a processor is 16-bit machine, it can distinguish
216 different memory addresses where 16 bits of
data can be processed simultaneously at each
clock cycle
– 16 bit, 32 bit and 64 bit processors
..00000000
11001110
..00000001
00110011
..00000010
11100011
..00000011
01010101
..00000100
…..
Memory
• Main memory consists of RAM and
ROM
• RAM: Random access memory
– CPU can directly address a byte of RAM
– Change contents of memory
– Volatile: Contents are erased when computer is turned
off
– Fast access: Store running programs
• ROM: Read only memory
– Contents cannot be changed
– Why do need ROM?
– Permanent data: cannot be erased and is not volatile,
stable
More about RAM
• What if you use up the RAM available?
– When can this happen?
• Swapping: Using a section of the hard drive for temporary use
as working memory
• Excessive swapping causes thrashing
– Undesirable!
– Reduces overall performance. Why?
– What is a possible long term solution?
• What if a program cannot find the memory it needs during
execution?
Secondary Storage Devices
• Magnetic Tapes
– Tape recorder
– Archival data storage
– Drawback: Sequential access
• Magnetic Disks (Hard drive)
– Read/write head
– Permanent storage
– Thin disk made out of
magnetic materials
• Tracks, sectors and blocks
– Efficiency
Hard Drive
Block
• Seek time, latency, access time, Track
transfer rate
Sector
A single disk
Secondary Storage Devices
• CD: compact discs
–
–
–
–
Made optically with a laser beam
Consists of one track that spirals from inside out
Track is broken into sectors like magnetic disc
CD-DA, CD-ROM, CD-RW, CD-WORM
• DVD: digital versatile disk
– Store up to 10 GB of data
• CD and DVD drive speeds: x16
– Faster is not always better
– Maximums listed are attainable at certain parts of
the disk
Input Devices
• Mouse
• Keyboard
• Camera
• Scanner
• Microphone
Non Traditional Input Devices
• Data gloves
• Touch screens
• Pen displays
Touch Screens
• Electronic visual display that can
detect the presence and location
of touch within the display area
• Pervasive: kiosks, restaurants,
museums, personal devices
• Choices are presented graphically
for fast but limited interaction
• Stylus
How do they work?
• Resistive touch screen
•
Two layers of conductive material separated
by a small space. When touched, the layers
come into contact, allowing current flow
• Why resistive touch?
•
•
•
•
•
Cost-effective
Very accurate
Low power requirements
Liquids do not affect performance
Works with any stylus
• Disadvantages:
•
•
Surface material can be damaged
Low endurance (~ 35 million touches)
How do they work?
• Capacitive touch screen
•
Laminate applied over a glass screen that can
conduct electricity
• Why capacitive touch?
•
•
•
•
•
Scratch resistant, durable surface
High endurance (~225 million touches)
Very accurate
Good optical clarity
Liquids do not affect performance
• Disadvantages:
•
Does not work with stylus or gloved finger
How do they work?
• Infrared touch screen
•
Projects crisscrossing vertical and horizontal
beams of infrared light over the surface of the
screen
• Why capacitive touch?
•
•
•
Better optical clarity than resistive or
capacitive screens
Able to handle dual touch input
Can scale to larger sizes
• Disadvantages: ?
Output Devices
• Display
• Printer
• Speakers
Non Traditional Output Devices
• Head Mounted display
• CAVE system
Cave Automatic Virtual Environment
Head Mounted Display
Computer Ads
16 bit
microprocessor
65K Bytes
Harddrive,
RAM
64 color video
board
Floppy Disks,
CD/DVD
Editor package
Operating System
Recap
• Von Neumann architecture
– Input/output devices
– CPU : ALU & Main memory &
Control unit
Input
device
• RAM: Volatile
• ROM: Permanent storage
– Secondary storage devices
(Hard drive, CD/DVD)
– Fetch Execute cycle of CPU
• Instructions are processed using
main memory and registers
Central Processing Unit
Output
device
Control Unit
Arithmetic/Logic
Unit
Auxiliary
storage
device
Memory Unit
Objectives
• Role of an operating system
• Manages resources
– Memory
– CPU
– Secondary storage
– I/O devices
Memory
CPU
Hard
Disk
Devices
What is an operating system?
• A system software that manages the
computer hardware and provides common
services for efficient execution of various
application software
– Examples: Windows 7, Mac OSX, Linux
• Application software are programs that
help us solve real world problems
– Examples: Accounting software, graphics
software, office suites, media players
Human Users
Application Software
Operating System
Other system software
Hardware
Early computers
In 1950s
• No operating system
• Only one program can be run at a time
• Person had to make an appointment and
arrive with program that needs to be run
– Program was coded in punched cards
• Notion of job queue was formed –
programs in a queue
– Libraries of software linked to user program
– Early operating system
Roles of an operating system
System software that
• Manages computer resources, such as memory and
input/output devices
• Provides an interface through which a human can interact
with the computer
• Allows an application software to interact with these other
system resources
Share resources nicely!
Resource Management
• Recall: Executing program resides in main memory
– Processed in the CPU by fetch- execute cycle
• In the real world, we have multiple programs running
– Multiprogramming: technique for keeping multiple
programs in main memory competing for CPU
• Memory management: Keeping track of programs in memory
and their addresses (location in memory)
– Each active program (in execution) in memory is called a
process
– Keeping careful track of processes and their different
states is known as process management
– Keeping track of processes getting CPU time is CPU
scheduling
• OS itself is a software that gets CPU time as well
Memory Management
• Multiprogramming
– Track where and how a program resides in memory
– How much memory should be allocated?
– A program (with variables, data) when complied is given an address
in memory
– Convert logical program addresses into actual memory addresses
• Address: Identifier for a memory location
• Logical address: Relative address (value) which specifies a
generic location relative to the starting address of the
program
• Physical address: Actual existing address in main memory
• Address binding: Scheme that maps a logical address to a
physical address in main memory
Single contiguous allocation
• Program is loaded in to memory as a single
continuous block of addresses
Operating System
Logical address: L
A
A+L
Memory
Application
Application
Program
Program
Boundary
Single contiguous allocation
Advantages:
• Simple to implement and manage
Disadvantages:
• Inefficient use of memory and CPU time
Main Memory
Operating System
Wait!
Program 2
Program 1
Partition memory allocation
• Allow more than one program access to main
memory
– Partitioning the memory space
Main Memory
Operating System
Program 1
Program 2
Program 3
Wait!
Program 4
Program 2
Wait!
Partition memory allocation
• Partitioning:
– Fixed : divided into specific number of partitions of variable size into
which programs are loaded
• Easier to manage than dynamic ones
– Dynamic: Memory is divided into partitions as needed to
accommodate programs
Main Memory
Program 1
Operating System
Program 1
Program 2
Program 2
Program 3
Program 3
Wait!
Program 4
Empty
Partition memory allocation
What partition should we allocate to a new program?
• First fit: a program needing space is given the first partition big
enough to hold it
• Best fit: a program in allocated to the smallest partition big enough
to hold it
– Can result in a lot of small partitions in memory that are useless
• Worst fit: a program is allocated to the largest partition big enough
to hold it
– Does not make sense for fixed partitions
– Makes sense for dynamic partition
– In dynamic partition, jobs can be shuffled around and make
space for one large free partition. This process is called
compaction.
Paged memory allocation
Main Memory
In this technique:
• Main memory divided into fixed size
blocks called frames
• A process (or program in execution) is
divided up into blocks called pages
• Pages are loaded into available frames – a
single process may be scattered around
– A page-map table is used by the OS to keep
track of pages of a process
• Advantage:
– Does not need to be stored contiguously in
memory
Frame
Contents
0
1
P2/Page2
2
3
P1/Page0
4
P1/Page2
5
6
P2/Page3
.
.
.
.
Process management
Processes move through specific states as they are managed in a
computer system
Prog 1
Waiting
Input/Output
or event wait
Input/Output or
event completion
Interrupt
Prog
Prog
Prog121
Ready
0
1
Running
Prog 2
1
Dispatch
. . .Prog 2 Prog 1
New
Admitted to
CPU
Exit
Terminated
Process control block
How does the CPU keep track of various processes?
• Process control block (PCB): Data structure which manages
information about a process
– Every process needs a PCB
CPU scheduling
How do processes get CPU time? How does the OS make sure
that the CPU is ‘shared nicely’ by the processes?
• CPU scheduling is the act of determining which process in the
ready state should be moved to the running state
–Non preemptive scheduling: Decisions made by the CPU when
the current process in the running state gives up the CPU
voluntarily
–Preemptive scheduling: Decisions made when the OS favors
another process and switches the current process for another one
• Turnaround time: CPU scheduling metric that measures the
elapsed time between a process’s arrival and its completion
– Average time to be small!
First come first served (FCFS)
• Processes are moved to the CPU in the order they arrive
• Gantt chart: a bar chart used to display a schedule
Process
Time/ms
P1
24
P2
3
P3
3
P1
0
P2
24
Average turnaround time = (24+27+30)/3 = 27 ms
P3
27
30
Shortest job first (SJF)
• Processes with the shortest service time are processed first
P2
0
P3
3
Process
Time/ms
P1
24
P2
3
P3
3
P1
6
Average turnaround time = (3+6+30)/3 = 13 ms
30
Round Robin (RR)
• Processing time is distributed equitably among all ready processes.
• Time slice: The amount of time given to each process. The CPU will give up
the process for another one once the time is up.
P1
0
P2
4
Process
Time/ms
P1
24
P2
3
P3
3
P3
7
P1
10
P1
14
Time slice is 4 ms
P1
18
P1
22
Average turnaround time = (30+7+10)/3 = 15.67 ms
P1
26
30
Performance characteristics
Which scheduling algorithm is better?
Algorithm
Average Turnaround
time/ms
FCFS
27
SJF
13
RR
15.67
• Hard to determine based on this example!
– Each algorithm is optimal for specific set of processes
• Round Robin
– Good average turnaround time
– Interactive or timesharing systems
– Most widely used and fair
• Shortest job first
– Best average turnaround time
– Comes with overhead since CPU service time needs to be determined and processes
sorted accordingly