Professional Documents
Culture Documents
Todays Overview
Any Questions? The instruction cycle Interrupts Interconnection Structures Group projects
Interrupts
A computer system must provide a method for allowing mechanisms to interrupt the normal processing. Interrupts improve processor efficiency Most external devices are much slower than the processor and busy waiting takes up too many resources. Examples:
External interrupts: Timing device, Circuit monitoring the power supply, I/O device requesting data or completed data transfer etc. Timeout errors. Internal interrupts (caused by an exception condition). Illegal use of an instruction or data (traps) example: register overflow, attempt to divide by zero, invalid op code, stack overflow etcTimer: OS system can perform operations on a regular basis. Software Interrupts Special call instruction that behaves like an interrupt.
Benefits of Interrupts
No Interrupts
1
WRITE
1
WRITE 2a
4
I/O Command
2
END WRITE
Interrupt Handler 2b
5
WRITE END 3a
3
3b WRITE WRITE
Short I/O the I/O operation is completed within the time it takes to execute instructions in the program that occur before the next I/O command. The processor is kept busy the whole time. Long I/O - The next I/O command comes before first I/O has completed. Processor still needs to wait. Some time is saved !
No Interrupts
1 4 5
2
2b
3a
3b
An example
Busy Wait: Consider a computer that can execute two instructions that read the status register and check the flag in 1 s. Input device transfers data at an average rate of 100 bytes per second equivalent to one byte every 10,000 s. The CPU will check the flag 10,000 times between each transfer. Interrupt Driven: CPU could use this time to perform other useful processing.
Interrupt Cycle
The interrupt cycle is added to the instruction cycle. Processor checks for interrupt indicated by an interrupt flag. If there is NO interrupt Fetch next instruction If there is an interrupt:
Suspend operation of the program Save its context Set PC to start address of the interrupt handler Process the interrupt Restore the context of the original program and continue its execution.
Define priorities
Low priority interrupts can be interrupted by higher priority interrupts When higher priority interrupt has been processed, processor returns to previous interrupt
Nested approach a higher priority device can interrupt a lower priority one.
(+) More complex (-) Interrupts get handled in order of priority.
Priority Interrupts
Polling
One common branch address for all interrupts. Interrupt sources polled in priority sequence. If an interrupt signal is on, control branches to a service routine for this source. (-) Time overhead to handle many interrupts can be excessive. The operation can be sped up with a hardware priority-interrupt unit.
Daisy-Chain Priority
Hardware solution Serial connection of all devices that request interrupts. Device with the highest priority takes first position, 2nd highest takes 2nd position etc. Interrupt request line shared by all devices.
VAD 1 Device 1 PI P0
Interrupt Request
INT
CPU
INTACK
Interrupt Acknowledge
PI
.
RF
.
PI Delay 0 0 1
Interrupt request to CPU
Vector Address
S R
PO
Priority Out
RF 0 1 0 1
PO Enable 0 0 1 0 0 0 0 1
Open-collector inverter
0 1
I0 I1 I2 I3 y x 0 0 0 0 0 0
Enable
Reader
From: Computer System Architecture, Morris Mano
2 3
Keyboard
0 1 2
IEN
IST
Interrupt to CPU
3
INTACK from CPU Mask Register
Priority Encoder
Circuit that implements the priority function. Logic if two or more inputs arrive at the same time, the input having the highest priority will take precedence. I0 1 Inputs I1 I2 d d I3 d Outputs d Y IST 0 0 1
0 0 0 0
1 0 0 0
d 1 0 0
d d 1 0
0 1 1 d
1 0 1 d
1 1 1 0
IST = I0 + I1 + I2 + I3
Interrupt Cycle
The Interrupt enable flip-flop (IEN) can be set or cleared by program instructions. A programmer can therefore allow interrupts (clear IEN) or disallow interrupts (set IEN) At the end of each instruction cycle the CPU checks IEN and IST. If either is equal to zero, control continues with the next instruction. If both = 1, the interrupt is handled. Interrupt micro-operations:
SPSP 1 (Decrement stack pointer) M[SP] PCc Push PC onto stack INTACK 1 Enable interrupt acknowledge PC VAD Transfer vector address to PC IEN 0 Disable further interrupts Go to fetch next instruction
Stack
Keystroke input from the teletype and printer output to the teletype are controlled by the I/O module. The teletype is able to encode an alphanumeric symbol to an 8-bit word and decode an 8-bit word into an alphanumeric symbol. a. Describe how the processor using the first four registers listed in this problem, can achieve I/O with the teletype. b. Describe how the function can be performed more efficiently by also employing IEN. IF TIME: draw the circuit diagram for the priority encoder in the parallel priority interrupt hardware diagram.
Interconnection Structures
Memory: Outputs data. Inputs read, write, and timing signals, addresses, and data.
I/O Module. Outputs data & interrupt signals. Inputs control signals, data, and addresses.
CPU: Outputs address, control signals, and data. Inputs instructions data, and interrupt signals.
Bus Interconnection
Communication pathway connecting two or more devices. Shared transmission medium - usually broadcast. Typically 50 100s of separate lines divided into three functional groups:
Data lines At this level data and instruction are synonymous. Width is a key determinant of performance. (Example: 32 bit words, data bus 16 bits 2 cycles to transmit one word). Address lines Identify source or destination of data (ie address in memory) Width determines maximum memory capacity of system (ie 8080 has 16 bit address 64K address space). Control lines Control lines Control and timing signals (read, write, ack, clock)
Bus Interconnection
Parallel lines on circuit boards Ribbon cables Strip connectors on mother boards Sets of wires
Arbitration Method
Only one module can have control of the bus at any one time. Centralized vs. Distributed
Timing
Synchronous vs. Asynchronous
Bus Width
Address Data
Bus Arbitration
Hardware arbitration
Serial arbitration daisy chain Parallel arbitration
Bus arbiter 1 Bus arbiter 2 Bus arbiter 3 Bus arbiter 4
2 X 4 Decoder
Synchronous Timing
Occurrence of events on the bus coordinated by a clock. Bus includes a clock line. Clock transmits alternating 1s and 0s of equal duration. A single 1-0 transmission = 1 clock cycle. All events start at the beginning of a clock cycle.
Stable Address
Valid Data In
Occurrence of one event follows the occurrence of a previous event. For read place status and address on the line. Once stabilized, place a read signal on the bus. Memory decodes address, and places data on the bus. Processor sends and ACK all lines can then be dropped.
Unit of Transfer
For internal memory this is equal to the number of data lines into and out of the memory module. Word length or longer (ie 64, 128, or 256 bits)
Concepts of Size
Word: Natural unit of organization within memory. No. or bits to represent a number, Length of one instruction. Many exceptions. Addressable Units: Either word or byte. Maximum addressable units = 2A (where A = no. of bits in the address) Unit of transfer No. of bits read into and out of memory. Addressable unit or larger (block)
Access Method
Sequential Access
Data organized into units called records. Access is linear sequenced. Shared read/write mechanism that is physically moved to read/write data. Access time varied. Example: Tape Unit.
Direct Access
Shared read/write mechanism Individual records have a unique physical address / location. Access by direct access to general vicinity + local sequential searching. Example: Disk Units.
Access Method
Random Access
Each addressable location in memory has a unique, physically wired addressing mechanism. Access time is independent of previous accesses. Access time is constant. Example: Main Memory + some Caches.
Associative:
Random access type of memory Supports comparison of desired bit locations within a word for a specified match on many words simultaneously Word is retrieved based on a portion of its contents rather than its address. Constant retrieval time Example: Many caches.
Performance
Access Time (latency)
Random Access = time taken to perform a read or write. Non-random access memory = time to position read-write mechanism at desired location.
Transfer Rate
Rate at which data can be transferred into or out of a memory unit. For random access memory = 1/(cycle time). Non random-access memory TN = TA + ( N / R)
TN = Average time to read or write N bits TA = Average access time N = Number of bits R = Transfer rate, in bits per second (bps)
Magnetic Disks
Tracks: Hard Disk platters arrange data into concentric circles, rather than one large spiral, as some other mediums use. Each circle is called a Track. Sectors: The smallest addressable unit on a Track. Sectors are normally 512 bytes in size, and there can be hundreds of sectors per track, depending on location. (Constant bit density more sectors on outer tracts) Heads: The devices used to write and read data on each platter. Cylinders: Platters on a hard disk are stacked up, and so are the heads. Concentric circles from each parallel platter form a cylinder. (Think Stargate!)
Example
What is the average time to read or write a 512-byte sector for a disk? The advertised average seek time is 5ms, the transfer rate is 40MB/sec, it rotates at 10,000 RPM, and the controller overhead is 0.1ms. Assume the disk is idle so that there is no queueing delay. In addition, calculate the time assuming the advertised seek time is three times longer than the measured seek time. Answer: Average disk access = average seek time + average rotational delay + transfer time + controller overhead.
5ms
0.5
+ 0.5KB
+ 0.1ms
10,000 RPM
40 MB/sec
Memory Hierarchy
Trade-offs Speed Cost Size