read_ide_sector(sector_num, buffer)
CPU Usage ------- -------
Disk Usage -----------------------------------------
Solution: double buffering
CPU Usage -Process 1----Process 2----Process 3---...
Disk Usage -Read 1-------Read 2-------Read 3-------Read 4------...
Requires 2 sectors of memory, but 2x throughput.
|-----|
| CPU |
|-----|<---data back------
| | ------insl instr.--->
-----------------------------------
V | data to ram |
|-----| ( Disk )
| RAM |
|-----|
|-----|
| CPU |
|-----|
| ------insl instr.--->
-----------------------------------
| <---data back------ | (directly to RAM)
|-----| ( Disk )
| RAM |
|-----|
void wait_for_ready() {
while (inb(0x147) & 0xc0 != 0x40) {
yield(); // give up CPU to another program
}
}
Also known as multiprogramming.
There are lots of solutions and methods here—why can’t all applications use the same one? For example, take read_ide_sector
and let all applications reference. (Would help with cache locality.)
Why not put a shared function in ROM? Make sure all applications know which address to reference it.
However, much more preferred to chain load our shared libraries, load it into RAM.