π -> 11/22: IO
π€ 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:
- Pause other task
- Check the caller ID
- Take the call
- Restart the other task
Implementation
- Running some program P
- I/O device generates an interrupt
- Save programβs state: EIP, EFLAGS, Seg
- Ask the I/O device for its interrupt id INTA
- Acknowledge interrupt
- I/O device gives back its interrupt Id
- Service the interrupt
- 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.
π -> Links
Resources
- Put useful links here
Connections
- Link all related words