Unit 5
Unit 5
Unit 5
The main memory is much larger but significantly slower than cache memories.
In a computer with a processor clock of 2 GHz or higher, the access time for the
main memory can be as much as 100 times longer than the access time for the
L1 cache.
Disk devices provide a very large amount of inexpensive memory, and they are
widely used as secondary storage in computer systems.
They are very slow compared to the main memory. They represent the bottom
level in the memory hierarchy.
CACHE MEMORIES
The speed of the main memory is very low in comparison with the speed of
modern processors.
For good performance, the processor cannot spend much of its time waiting to
arrangement.
An efficient solution is to use a fast cache memory which essentially makes
the main memory appear to the processor to be faster than it really is.
The effectiveness of cache mechanism is based on the property of computer
programs called Locality of reference.
Locality of Reference:
Many instructions in the localized areas of the program are executed repeatedly
during some time period and remainder of the program is accessed relatively
infrequently.
It manifests itself in 2 ways.They are,
very soon.)
Spatial (The instructions in close proximity to recently executed instruction
When a Read request is received from the processor, the contents of a block of
memory words containing the location specified are transferred into the cache
Memory.
The correspondence between main memory block and the block in cache memory is
specified by a mapping function.
The Cache control hardware decide that which block should be removed to create
space for the new block that contains the referenced word.
The collection of rule for making this decision is called the replacement
algorithm.
The cache control circuit determines whether the requested word currently exists
in the cache.
If it exists, then Read/Write operation will take place on appropriate cache
Write-through protocol
Write-back protocol
Write-through protocol:
Here the cache location and the main memory locations are updated
simultaneously.
Write-back protocol:
This technique is to update only the cache location and to mark it as with
The block of words that contains the requested word is copied from the main
memory into cache.
Load through:
After the entire block is loaded into cache, the particular word requested
main memory.
If Write back protocol is used then block containing the addressed word is first
brought into the cache and then the desired word in the cache is over-written
with the new information.
Mapping Function:
address.
The main memory has 64K words, which we will view as 4K blocks of 16 words
each.
Direct Mapping:
It is the simplest technique in which block j of the main memory maps onto block
it is stored in block 0.
Block 1,129,257 are stored in cache block 1 and so on.
The contention may arise when,
When more than one memory block is mapped onto a given cache
block position.
The contention is resolved by allowing the new blocks to overwrite the currently
resident block.
Placement of block in the cache is determined from memory address.
Merit:
It is easy to implement.
Demerit:
Associative Mapping:
In this method, the main memory block can be placed into any cache block
position.
12 tag bits are required to identify a memory block when it is resident in the
cache.
The tag bits of an address received from the processor are compared to the tag bits
of each block of the cache to see if the desired block is present. This is called
associative mapping.
Merit:
Demerit:
Set-Associative Mapping:
In this case, the cache has two blocks per set, so the memory blocks
0,64,128..4032 maps into cache set 0, and they can occupy either of the two
6 bit tag field The tag field of the address is compared to the tags of the two
blocks of the set to clock if the desired block is present.
Set-Associative Mapping
The cache which contains 1 block per set is called direct Mapping.
A cache that has k blocks per set is called as k-way set associative cache.
Each block contains a control bit called a valid bit.
The Valid bit indicates that whether the block contains valid data.
The dirty bit indicates that whether the block has been modified during its
cache residency.
Valid bit=0 When power is initially applied to system
Valid bit =1 When the block is loaded from main memory at first time. If the
main memory block is updated by a source & if the block in the source is
already exists in the cache, then the valid bit will be cleared to 0.
If Processor & DMA uses the same copies of data then it is called as the Cache
Coherence Problem.
Merit:
The Contention problem of direct mapping is solved by having few choices for
block placement.
The hardware cost is decreased by reducing the size of associative search.
Replacement Algorithm:
cache controller must decide which of the old blocks has to be replaced.
Therefore, when a block is to be over-written, it is sensible to over-write the one
that has gone the longest time without being referenced. This block is called Least
Eg:
Consider 4 blocks/set in set associative cache, 2 bit counter can be used for each
block.
When a hit occurs, then block counter=0;The counter with values
originally lower than the referenced one are incremented by 1 & all others
remain unchanged.
When a miss occurs and the set is not full, the counter associated with the
new block loaded from the main memory is set to 0, and the values of all
Merit:
The performance of LRU algorithm is improved by randomness in deciding which
block is to be over-written.
Several other replacement algorithms are also used in practice. A reasonable rule would
be to remove the oldest block from a full set when a new block must be brought in.
Many replacement algorithms didnt follow the access of cache, it is generally not as
effective as the LRU algorithm.
The simplest algorithm is to randomly choose the block to be overwritten. Interestingly
enough, this simple algorithm has been found to be quite effective in practice.
PERFORMANCE CONSIDERATION(Improving cache performance):
Two Key factors in the commercial success are the performance & cost. The
Interleaving:
If the main memory of a computer is structured as a collection of physically separate
modules, each with its own address buffer register(ABR) and data buffer
register(DBR), memory access operations may proceed in more than one module at
the same time.
Thus, the aggregate rate of transmission of words to and from the main memory system
can be increased.
How individual addresses are distributed over the modules is critical. Two methods of
address layout are there.
In the first case, the memory address generated by the processor is decoded. The high
order k bits name one of n modules, and the low-order m bits name a particular word
in that module.
When consecutive locations are accessed, when a block of data is transferred to a
cache, only one module is involved. At the same time, devices with direct memory
access(DMA) ability may be accessing information in other memory modules.
The second and more effective way to address the modules is called memory
interleaving.
The low order k bits of the memory address select a module, and the high order m bits
name a location within the module.
In this way, consecutive addresses are located in successive modules. Thus, any
component of the system that generates request for access to consecutive memory
locations can keep several modules busy at any one time.
This results in faster access to a block of data and higher average utilization of the
memory system as a whole.
Interleaving is used within SDRAM chips to improve the speed of accessing
successive words of data.
Hit rate and miss penalty:
The effective implementation of the memory hierarchy is the success rate in accessing
information at various levels of the hierarchy.
The successful access to data in a cache is called a hit. The number of hits are stated as
a fraction of all attempted accesses is called the hit rate, and the miss rate is the
number of misses stated as a fraction of attempted accesses.
Ideally, the entire memory hierarchy would appear to the processor as a single memory
unit that has the access time of a cache on the processor chip and the size of a
magnetic disk.
How close, ideal it is, depends largely on the hit rate at different levels of the hierarchy.
High hit rates are essential for high-performance computers, wil over 0.9.
Performance is affected by the miss. The extra time needed to bring the desired
information into the cache is called the miss penalty. This penalty make the processor
to stall.
In general, the miss penalty is the time needed to bring a block of data from a slower
unit to a faster unit. The miss penalty is reduced, if efficient mechanisms are
implemented.
How can the hit rate be improved? An obvious possibility is to make the cache larger,
but with increased cost. Another possibility is to increase the block size while
keeping the total cache size constant to take advantage of spatial locality.
If all items in a larger block are needed in a computation, then it is better to load these
items into the cache as a consequence of a single miss, rather than loading several
smaller blocks as a result of several misses. The efficiency of parallel access to
blocks in an interleaved memory is the basic reason for this advantages.
The performance of a computer is affected positively by increased hit rate and
negatively by increased miss penalty, the block sizes that are neither very small nor
very large give the best results.
In practice, block sizes in the range of 16 to 128 bytes have been the most popular
choices.
Note: that the miss penalty can be reduced if the load-through approach is used when
loading new blocks into the cache.
Caches on the processor chip:
The space on the processor chip is needed for many other functions, this limits
same time, which leads to increased parallelism, and hence, better performance.
Disadvantages: increase parallelism comes at the expense of more complex
circuitry.
In high performance processors two levels of caches are normally used. The L1
cache is on the processor chip. The L2 cache, which is much larger, may be
implemented externally.
If both L1 and L2 caches are used, the L1 cache should be designed to do fast
access. A practical way to speed up access to the cache is to access more than
one word simultaneously and let the processor use them one at a time. This is
levels of caches is
t ave = h1C1 + (1-h1)h2C2+(1-h1)(1-h2)M
Where h1 is the hit rate in the L1 cache
h2 is the hit rate in the L2 cache
C1 is the time to access information in the L1 cache
C2 is the time to access information in the L2 cache
M is the time to access information in the main memory.
Other enhancements:
Several other possibilities exist for enhancing performance.
Write Buffer:
When the write-through protocol is used, each write operation results in writing a
write requests.
The processor places each write request into this buffer and continues execution of
Prefetching
The new data are brought into the cache when they are first needed. A read miss
occurs, and the desired data are loaded from the main memory. The processor has
before they are needed. The simplest way to do this is through software.
A special prefetch instruction may be provided in the instruction set of the
processor. Executing this instruction causes the addressed data to be loaded into
according to that.
Example: Intels Pentium 4 processor has facilities for prefetching information
into its caches using both software and hardware approaches. There are special
prefetch instructions that can be included in programs to bring a block of data into
a desired level of cache.
Lookup-free cache:
A cache that can support multiple outstanding misses is called lookup-free. Since
it can service only one miss at a time, it must include circuitry that keep tracks of
all outstanding misses. This may be done with special registers that hold the
VIRTUAL MEMORY:
In most modern computer systems, the physical main memory is not as large
as the address space spanned by an address issued by the processor. For
example, a processor that issues 32-bit address has an addressable space of
4G bytes.
Techniques that automatically move program and data blocks into the
physical main memory when they are required for execution is called the
Virtual Memory.
The binary address that the processor issues either for instruction or data
/accessed immediately.
If the data are not in the main memory, the MMU causes the Operating system to
main memory.
The pages are commonly range from 2K to 16K bytes in length.
The cache bridge speed up the gap between main memory and secondary storage and
it is implemented in software techniques.
Each virtual address generated by the processor contains virtual Page
number(Low order bit) and offset(High order bit)
Virtual Page number+ Offset Specifies the location of a particular byte (or word)
within a page.
Page Table:
It contains the information about the main memory address where the page is
stored & the current status of the page.
Page Frame:
An area in the main memory that holds one page is called the page frame.
Virtual Page Number + Page Table Base register Gives the address of the
corresponding entry in the page table.ie)it gives the starting address of the page if that
page currently resides in memory.
Control Bits in Page Table:
The Control bits specifies the status of the page while it is in main memory.
Function:
The control bit indicates the validity of the page ie)it checks whether the page is
The Page table information is used by MMU for every read & write access.
The Page table is placed in the main memory but a copy of the small portion of
This small portion or small cache is called Translation Look Aside Buffer
(TLB). This portion consists of the page table entries that corresponds to the
If the page table entry for this page is found in TLB, the physical address is
obtained immediately.
If there is a miss in TLB, then the required entry is obtained from the page table in
most recently accessed pages and also contains the virtual address of the entry.
When the operating system changes the contents of page table ,the control bit in
can proceed.
When it detects a page fault, the MMU asks the operating system to generate an
interrupt.
The operating System suspend the execution of the task that caused the page fault
and begin execution of another task whose pages are in main memory because the
Address
Data
Control Signals.
Each I/O device is assigned a unique set of addresses.
When the processor places a particular address on address lines, the devices that
recognize this address responds to the command issued on the control lines.
The processor request either a read or write operation and the requested data are
Address Decoder:
It enables the device to recognize its address when the address appears on address lines.
Data register
Status register It contains information relevant to the operation of the I/O devices.
Both the data and status registers are connected to the data bus and assigned unique
address.
The address decoder, data & status registers and the control circuitry required to coordinate I/O transfers constitute the devices interface circuit.
For an input device, SIN status flag in used SIN = 1, when a character is entered at the
keyboard.
For an output device, SOUT status flag is used SIN = 0, once the char is read by
processor.
Hence, by checking the SIN flag, the software can ensure that it is always reading valid
data.
This is often accomplished in a program loop that repeatedly reads the status register and
checks the state of sin.
Registers in keyboard and display interfaces
keyboard enable.
DEN
Display Enable.
EXPLANATION:
This program, reads a line of characters from the keyboard & stores it in a memory
buffer starting at locations LINE.
Then it calls the subroutine PROCESS to process the input line.
As each character is read, it is echoed back to the display.
Register Ro is used as a updated using Auto increment mode so that successive
characters are stored in successive memory location.
Each character is checked to see if there is carriage return (CR), char, which has the
ASCII code 0D(hex).
If it is, a line feed character (on) is sent to more the cursor one line down on the display
& subroutine PROCESS is called. Otherwise, the program loops back to wait for another
character from the keyboard.
PROGRAM CONTROLLED I/O
Here the processor repeatedly checks a status flag to achieve the required
synchronization between Processor & I/O device.(ie) the processor polls the device.
Programmed Input/ Output, a method for controlling Input/ Output operations, which is
included in most computers.
It is particularly useful in small low- speed systems where hardware costs must be
minimized.
It requires that all input/ output operators be executed under the direct control of the
CPU, i.e., every data- transfer operation involving an input/ output device requires the
execution of an instruction by the CPU.
Typically, the data transfer is between CPU registers and a buffer register connected to
the input/ output device.
The input/ output device does not have direct access to main memory.
A data transfer from input/ output device to main memory requires the execution of
several instructions by the CPU, including an input instruction to transfer a word from
the input/ output device to the CPU and a store instruction to transfer a word from CPU
to main memory.
1 or 2 additional instructions may be needed for address computation and data word
counting.
Direct memory access is a technique used for high-speed I/O devices. It involves having
the device interface transfer data directly to or from the memory, without continuous
involvement by the processor.
Input/ Output Addressing:
In systems with programmed Input/ output, in devices, main memory and the CPU
normally communicate via a common shared bus.
The address lines of that bus which are used to select main- memory locations can also
be used to select input/ output devices.
Each junction between the system bus and input/ output device is called input/ output
port and is assigned a unique address.
The input/ output port includes a data buffer registers, thus making if little different from
a main memory location with respect to the CPU.
Memory mapped Input/ Output:
Some machines, such as Motorola 68000 microprocessor series, is to assign part of the
main memory address space to input/ output ports. This is called Memory- mapped
input/ output.
A memory referenced instructions that causes data to be fetched from or stored at address
X automatically becomes an input/ output instruction if X is made the address of an I/O
port.
The memory load and store instruction are used to transfer a word of data to or from an
I/O port; no special I/O instructions are needed.
The control lines READ and WRITE, which are activated by the CPU on decoding a memory
reference instructions, are used to initiate either a memory access cycle or an I/O transfer.
I/O mapped I/O:
In I/O mapped I/O technique, the memory and I/O address space are kept separate a
memory reference instruction activation the READ M or WRITE M control line does
not affect the I/O devices.
Separate I/O instructions are required to activate the READ IO and WRITE IO lines,
which causes a word to be transferred between the addressed IO port and the CPU.
An IO address and a main- memory location may have the same address. This scheme is
used, for example, in the Intel 8085 and 8086 microprocessor series.
IO Instructions:
Programmed IO can be implemented by a few as 2 IO instructions.
For example, the Intel 8085 has 2 main IO instructions. The instruction IN X causes a
word to be transferred from IO port X to the 8085s accumulator register.
The instruction OUT X transfer a word from the accumulator to IO port X.
When IO instructions IN or OUT is encountered by the CPU, the addressed IO port is
expected to be ready to respond to the instruction. This means that the IO device must
transfer data to or from the data bus within the specified period.
To prevent loss of information or an indefinitely long IO instruction execution time, it is
thus desirable that the CPU know the IO device status, so that a data transfer is carried
out when the device is in the known ready state.
In programmed IO system, the CPU is usually programmed to test the IO device states
because initiating the data transfer.
Status can be specified by a single bit of information that the IO device can make
available on a continuous basis e.g., by setting a flip- flop connected to the data lines at
some IO port.
The determination of IO device status by the CPU requires the following steps.
o Step1:Read the status information.
o Step2: Test the status to determine if the device is ready to begin data transfer.
o Step3:If not ready, return to step 1; otherwise proceed with the data transfer.
Example: Intel 8085 program to read one word from an Input/ Output device.
WAIT:
IN 1
CPI READY
JNZ WAIT
IN 2
Starting address
Direction of transfer.
When a block of data is transferred , the DMA controller increment the memory address
for successive words and keep track of number of words and it also informs the
Done Flag=1, the controller has completed transferring a block of data and isready to receive
another command.
Bit 30 is the Interrupt-enable flag, IE.
IE=1, it causes the controller to raise an interrupt (interrupt Enabled) after it hascompleted
transferring the block of data.
IRQ=1, it indicates that the controller has requested an interrupt.
A DMA controller connects a high speed network to the computer bus. The disk
controller two disks, also has DMA capability and it provides two DMA channels.
To start a DMA transfer of a block of data from main memory to one of the disks, the
program write s the address and the word count inf. Into the registers of the
retrieval.
The DMA controller proceeds independently to implement the specified operation.
When DMA transfer is completed, it will be recorded in status and control registers of
the DMA channel (ie) Done bit=IRQ=IE=1.
Cycle Stealing:
Requests by DMA devices for using the bus are having higher priority than processor requests.
Top priority is given to high speed peripherals such as ,
Disk
Burst Mode:
The DMA controller may be given exclusive access to the main memory to transfer a
block of data without interruption. This is known as Burst/Block Mode
Bus Arbitration:
Bus Master:
The device that is allowed to initiate data transfers on the bus at any given time is called
status.
It is the process by which the next device to become the bus master is selected and the
bus mastership is transferred to it.
Types:
There are 2 approaches to bus arbitration. They are,
Centralized Arbitration:
The bus arbiter may be the processor or a separate unit connected to the bus.
Here the processor is the bus master and it may grants bus mastership to one of its DMA
controller.
A DMA controller indicates that it needs to become the bus master by activating the Bus
The timing diagram shows the sequence of events for the devices connected to the
processor is shown.
DMA controller 2 requests and acquires bus mastership and later releases the bus. During
its tenure as bus master, it may perform one or more data transfer.
After it releases the bus, the processor resources bus mastership.
The timing diagram shows the sequence of events for the devices connected to the
processor is shown.
DMA controller 2 requests and acquires bus mastership and later releases the bus. During
its tenure as bus master, it may perform one or more data transfer operations, depending
Distributed Arbitration:
It means that all devices waiting to use the bus have equal responsibility in carrying out
the arbitration process, without using a central arbiter.
highest ID number.
The drivers are of open collector type. Hence, if the i/p to one driver is equal to 1, and
the i/p to another driver connected to the same bus line is equal to 0(ie. bus the is in lowvoltage state).
Eg:
Assume two devices A & B have their ID 5 (0101), 6(0110) and their code is 0111.
Each devices compares the pattern on the arbitration line to its own ID starting from
MSB.
If it detects a difference at any bit position, it disables the drivers at that bit position and
for all lower-order bits. It does this by placing 0 at the i/p of these drivers.
In our eg. A detects a difference in line ARB1, hence it disables the drivers on lines
ARB1 & ARB0.
This causes the pattern on the arbitration line to change to 0110 which means that B has
INTERRUPTS
The program enters a wait loop in which it repeatedly tests the device status. During this
period, the processor will not performing any useful computation.
There are many situations where other tasks can be performed while waiting for an I/O
device to become ready. To allow this to happen, we can arrange for the I/O device to
alert the processor when it becomes ready.
It can do so by sending a hardware signal called an interrupt to the processor. At least
one of the bus control lines, called an interrupt request line.
The Interrupt request line will send a hardware signal called the interrupt signal to the
processor.
On receiving this signal, the processor will perform the useful function during the
waiting period.
Consider a task that requires some computations to be performed and the results to be
printed on a line printer.
This is followed by more computations and output, and so on.
Let the program consist of two routines, COMPUTE and PRINT.
Assume that COMPUTE produces a set of n lines of output, to be printed by the PRINT
routine.
The processor first completes the execution of instruction i Then it loads the PC(Program
Counter) with the address of the first instruction of the ISR. After the execution of ISR,
the processor has to come back to instruction i + 1.
Therefore, when an interrupt occurs, the current contents of PC which point to i +1 is put
in temporary storage in a known location.
A return from interrupt instruction at the end of ISR reloads the PC from that temporary
storage location, causing the execution to resume at instruction i+1. When the processor
is handling the interrupts, it must inform the device that its request has been recognized
so that it remove its interrupt requests signal.
This may be accomplished by a special control signal called the interruptacknowledge
signal.
The task of saving and restoring the information can be done automatically by the
processor.
The processor saves only the contents of program counter & status register (ie) it
saves only the minimal amount of information to maintain the integrity of the program
execution.
Saving registers also increases the delay between the time an interrupt request is received
and the start of the execution of the ISR. This delay is called theInterrupt Latency.
Generally, the long interrupt latency in unacceptable.
The concept of interrupts is used in Operating System and in Control Applications,
where processing of certain routines must be accurately timed relative to external events.
This application is also called as real-time processing.
Interrupt Hardware:
A single interrupt request line may be used to serve ndevices. All devices are connected
to the line via switches to ground.
To request an interrupt, a device closes its associated switch, the voltage on INTR line
drops to 0(zero).
If all the interrupt request signals (INTR1 to INTRn) are inactive, all switches are open
and the voltage on INTR line is equal to Vdd. This is the inactive state of line
When a device requests an interrupts by closing its switch, the voltage on the line drops
to 0, causing the interrupt request signal, INTR, received by the processor to go to 1.
Since the closing of one or more switches will cause the line voltage to drop 0, the value
of INTR is the logical OR of the requests from individual devices. That is,
(ie) INTR = INTR1++INTRn
An equivalent circuit for an open drain bus used to implement a common interrupt request line
INTR It is used to name the INTR signal on common line it is active in the lowvoltage state.
Open collector (bipolar circuit) or Open drain (MOS circuits) is used to drive
INTRline.
The Output of the Open collector (or) Open drain control is equal to a switch to the
ground that is open when gates input is in 0 state and closed when the gates input is in1
state.
Resistor Ris called a pull-up resistor because it pulls the line voltage upto the high
voltage state when the switches are open.
Enabling and Disabling Interrupts:
The arrival of an interrupt request from an external device causes the processor to
suspend the execution of one program & start the execution of another.
Becauseinterrupts can arrive at any time, they may alter the sequence of events from that
envisaged by the programmer.
Hence, the interruption of program execution must be carefully controlled.
A fundamental facility found in all computers is the ability to enable and disable such
interruptions as desired.
There are many situations in which the processor should ignore interrupt requests. For
example, in the case of Compute-Print program, an interrupt request from the printer
should be accepted only if there are output lines to be printed.
After printing the last line of a set of n lines, interrupts should be disabled until another
set becomes available for printing.
In another case, it may be necessary to guarantee that a particular sequence of
instructions is executed to the end without interruption because the interrupt-service
routine may change some of the data used by the instructions in question.
A simple way is to provide machine instructions, such as Interrupt-enable and Interrupt-
responds only to the leading edge of the signal. Such a line said to be edge-triggered.
The following are the typical scenario.
The device raises an interrupt request.
The processor interrupts the program currently being executed.
Interrupts are disabled by changing the control bits is PS (Processor Status register)
The device is informed that its request has been recognized & in response, it deactivates the
INTR signal.
The action requested by the interrupt is performed by the interrupt service routine.
Interrupts are enabled & execution of the interrupted program is resumed.
are.
These problems are resolved vary from one computer to another, and the approach taken
is an important consideration in determining the computers suitability for a given
application.
Polling Scheme:
When a request is received over the common interrupt request line, additional
information is needed to identify the particular device that activated the line.
If two devices have activated the interrupt request line, the ISR for the selected device
(first device) will be completed & then the second request can be serviced.
The information needed to determine whether a device is requesting an interrupt is
available in its status register. When a device raises an interrupt request, it sets to 1 one
of the bits in its status register, which we will call the IRQ bit.
The simplest way to identify the interrupting device is to have the ISR polls all the
encountered with the IRQ bit set is the device to be serviced.
KIRQ and DIRQ are the interrupt request bits for the keyboard and the display,
respectively.
IRQ (Interrupt Request) -> when a device raises an interrupt requests, the status register
IRQ is set to 1.
Merit:
It is easy to implement.
Demerit:
The time spent for interrogating the IRQ bits of all the devices that may not be requesting any
service.
Vectored Interrupt:
To reduce the time involved in the polling process, a device requesting an interrupt may
identify itself directly to the processor.
Then the processor can immediately start executing the corresponding interrupt service
routine.
The term vectored interrupts refers to all interrupt handling schemes based on this
approach.
A device requesting an interrupt can identify itself by sending a special code to the
processor over the bus.
This enables the processor to identify individual devices even if they share a single
interrupt request line.
The code supplied by the processor indicates the starting address of the ISR for the
device.
The code length ranges from 4 to 8 bits.
The location pointed to by the interrupting device is used to store the staring address to
ISR.
The processor reads this address, called the interrupt vector & loads into PC. The
interrupt vector also includes a new value for the Processor Status Register. When the
processor is ready to receive the interrupt vector code, it activate the interrupt
Privileged Exception:
User program cannot accidently or intentionally change the priority of the processor &
Therefore, the device that is electrically closest to the processor has the highest priority.
KEN
DEN
KIRQ / DIRQ
Keyboard / Display unit requesting an interrupt.
There are two mechanism for controlling interrupt requests.
At the devices end, an interrupt enable bit in a control register determines whether the
device is allowed to generate an interrupt requests.
At the processor end, either an interrupt enable bit in the PS (Processor Status) or a
priority structure determines whether a given interrupt requests will be accepted.
Initiating the Interrupt Process:
Read the input characters from the keyboard input data register. This will cause the
interface circuits to remove its interrupt requests.
Store the characters in a memory location pointed to by PNTR & increment PNTR.
When the end of line is reached, disable keyboard interrupt & inform program main.
Return from interrupt.
Exceptions:
An interrupt is an event that causes the execution of one program to be suspended and
the execution of another program to begin.
The Exception is used to refer to any event that causes an interruption.
Kinds of exception:
System software has a program called debugger, which helps to find errors in a program.
The debugger uses exceptions to provide two important facilities They are
Trace
Breakpoint
Trace Mode:
When processor is in trace mode , an exception occurs after execution of every instance
using the debugging program as the exception service routine.
The debugging program examine the contents of registers, memory location etc. On
return from the debugging program the next instance in the program being debugged is
executed
The trace exception is disabled during the execution of the debugging program.
Break point:
Here the program being debugged is interrupted only at specific points selected by the
user.
An instruction called the Trap (or) software interrupt is usually provided for this purpose.
While debugging the user may interrupt the program execution after instruction I.
When the program is executed and reaches that point it examine the memory and register
contents.
Privileged Exception:
To protect the OS of a computer from being corrupted by user program certain instance
can be executed only when the processor is in supervisor mode. These are called
privileged exceptions.
When the processor is in user mode, it will not execute instruction. Whenthe processor is
in supervisor mode, it will execute instance.
Use of interrupts in operating systems:
The operating system is responsible for coordinating all activities within a computer.
It makes extensive use of interrupts to perform I/O operations and communicate with and
control the execution of user programs.
The interrupt mechanism enables the OS to assign properties, switch from one user
program to another, implement security and protection features, and coordinate I/O
activities.
The OS incorporates the interrupt-service routines for all devices connected to a
computer.
Application programs do not perform I/O operations themselves. When an application
program needs an input or an output operation, it points to to the data to be transferred
and asks the OS to perform the operation.
The OS suspends the execution of that program temporarily and performs the requested
I/O operation.
When the operation is completed, the OS transfers control back to the application
program. The OS and the application program pass control back and forth using software
interrupts.
In a computer that has both a supervisor and a user mode, the processor switches its
Input-output devices are the means by which a computer communicate with the outside
world. A primary function of IO devices is to act as data transducers, i.e., to convert
information from one physical representation to another. Unlike processors, IO devices
do not alter the information content or meaning of the data on which they act.
Since data is transferred and processed with a computer system in the form of digital
electrical signals, input devices transform other forms of information to or digital
electrical signals.
The below table lists some typical IO devices and the information medium they employ.
Note that many of these devices make use of electromechanical technologies; hence their
speed of operation slow compared with process and main memory speeds.
An IO devices can be controller directly by the CPU, but it is often under the immediate
control of a special purpose processor or control unit which directs the flow of
information between the processor and main memory.
IO PROCESSORS:
systems with programmed IO, peripheral devices are controlled by the CPU.
The DMA concepts extends to the IO devices limited control over data transfers to and
IO instructions:
In a computer system with IOPs, the CPU does not normally execute IO data-transfer
instructions.
Such instructions are contained is IO programs stored in main memory and are fetched and
The IO instructions executed by the IOP are primarily associated with data transfer.
A typical IOP instruction has the form:
Read(Write) block of n words from(to) device X to(from) memory region Y.
The IOP is provided with direct access to main memory(DMA) and so can control the
instruction set to facilitate the calculation of complex address, IO devices priorities etc..
A third category of IO instructions includes those executed by specific IO devices. These
IO devices.
The CPU supervises IO operations by means of a small set of privileged IO instructions
with the format of above figure (a). The address field specifies a based register B and a
displacement D, which identify both the 10 device to be used and the IOP to which it is
attached.
There are three major instructions of this type.
1. START IO
2. HALT IO
3. TEST IO
START IO is used to initiate an IO operation. It provides the IOP it names with the main
causes the number of bytes specified in the data count field to be transferred between the
data transfer.
The flags field of the CCW is used to modify or extend the operation specified its
opcode. Another flag specifies command changing, which means that the
current CCW.
IOP Organization:
The IOP and CPU share access to a common main memory M via the system bus.
M contains separate programs for execution by the CPU and the IOP; it also
contains a communication region IOCR used for passing information in the form
memory location 72, which is a part of the CPU- IOP communication region.
The CAW contains the absolute 24- bit starting address of the IO program to be executed by
bus.
This asynchronous IO bus contains over 30 unidirectional lines, including 2 8- bit data
If the status is valid, the IOP outputs a command byte indicating the IO operations to be
interrupt is generated.
The CPU can maintain direct control over the IO operation by periodically executing TEST
IO.
This causes the IOP to construct a channel status word CSW, which it stores at memory
location 64.
The CPU can then fetch the CSW and examine it. This type of programmed IO is an
inefficient way for the CPU to monitor IO operations, so the IOPs are provided with the
PSW as the old PSW at memory location 56 and fetches a new PSW from location 120.
The new PSW contain a program counter field pointing to the interrupt service routine to be
used.
If it is desired to save the CPU general registers, explicit instructions for this purpose must