πŸ“— -> 11/22: IO


Lecture Slide Link

🎀 Vocab

❗ Unit and Larger Context

Small summary

βœ’οΈ -> Scratch Notes

Wait Loop

  • Repeatedly ask I/O device if it has input
  • Once it does have input do something with it
  • Go back to asking for input
  • Disadvantages
    • Keeps the CPU busy asking for input and most of the time input is not available
    • Wasteful of CPU time
  • Advantages
    • Simple
    • Low latency: When the input shows up we get it quickly
    • Can all be done in software

Wait Loop I/O

On Intel PC, the keyboard data port (KDP) has address 0x60, and its status port (KSP) is at 0x64.
Among other things, the KSP tells us whether a key has been typed yet; Bit 4 will be 1 if so, 0 otherwise.

Can have another type of I/O in place of wait loop (wait loop just polls over and over again looking for input)

Interrupt Driven I/O

Waiting for call analogy:

Waiting for call, so doing something in the meantime. Steps to take from now on are:

  1. Pause other task
  2. Check the caller ID
  3. Take the call
  4. Restart the other task

Implementation

  1. Running some program P
  2. I/O device generates an interrupt
  3. Save program’s state: EIP, EFLAGS, Seg
  4. Ask the I/O device for its interrupt id INTA
    • Acknowledge interrupt
  5. I/O device gives back its interrupt Id
  6. Service the interrupt
  7. Resume program P
    • IRET: Interrupt RETturn

Interrupt Descriptor Table

  • OS maintains a table of Interrupt Vectors
  • Each vector stores the address of the ISR as well as some other information
    • Protection levels
  • Entries are indexed by the interrupt ID of the devices
  • Inside of the Intel CPU there is another register called IDT that stores the beginning of the address of the interrupt descriptor table in memory
  • OS filled in both the table as well as the register at boot time

Where do interrupts happen?

  • Interrupts are checked for at the end of every instruction
  • CPU Cycle: Fetch, Decode, Execute, Write, Check For Interrupt, Handle interrupt if there is one

This is the difference between doing doing a math problem and checking your phone between each problem, or doing it until your phone buzzes, then getting to it after you finish your problem.

Resources

  • Put useful links here

Connections

  • Link all related words