Last time

Performance Issues

Double Buffering

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.

Direct Memory Access

Original View

|-----|
| CPU |
|-----|<---data back------
 | | ------insl instr.--->
-----------------------------------
 V | data to ram        |
|-----|              ( Disk )
| RAM |
|-----|

Using DMA

|-----|
| CPU |
|-----|
   | ------insl instr.--->
-----------------------------------
   | <---data back------ | (directly to RAM)
|-----|              ( Disk )
| RAM |
|-----|

Yield

void wait_for_ready() {
	while (inb(0x147) & 0xc0 != 0x40) {
		yield(); // give up CPU to another program
	}
}

Also known as multiprogramming.

Motivation for an Operating System

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.