Monday, March 15, 2010

I/O and Interrupts

fraction of processor time consumed =k/t when
interrupt is generated every t sec and takes k sec to process interrupt
|------------t-----------|----k-----|

If DMA steals 1 cycle every k msec then
fraction CPU slow down is  1/k

Problem A microprocessor scans output I/O device every 20ms There are two interface ports status and output.Instruction takes 12 clock cycles.If clock is 8Mhz how long does it take to scan and service device.
Solution To check the status one instruction to read the status register, One instruction to verify content of register that is if ready or not and one more instruction if ready to feed data to device
each instruction takes (12*1)/(8*10^-6)=1.5microsec
so total of 3 instruction would take 4.5microsec

Problem If character is input in keyboard character buffer each k msec what should be scan rate
Scan should be done atleast 1 every k msec

Problem Average number of commands entered through keyboard is 60 per 8hr
If keyboard is scanned every 100ms then
1)number of times CPU scanned in 8hr?
2)number of scan if interrupt driven I/o is used
3)fraction
Solution  10 scan every sec so in 8hr its 8*60*60*10 scans
In interrupt driven I/O interrupt would be generated for each command so 60 interrupts
Problem Interrupt I/o is used on system with average 8KB/s transfer rate
1)if interrupt processing takes 100microsec. what fraction of time is consumed by i/o device if it interrupts for each byte
in a second it would interrupt 8000 times per sec or 1/8000 =1 every 125microsec
if each interrupt takes 100microsec
fraction  = 100/125
2) if device has 2 16byte bufer and interrupts the cpu after one buffer is full It takes 8microsec to transfer each byte then
it interrupts 8K/16B times that is 500 times every sec or 1 times every 2000microsec
100microsec for interrupt processing + 16*8microsec for transfer of each chracter

No comments:

Post a Comment