Polling
Handshaking
controller 用 busy bit 表示狀態,host 用 command-ready bit 表示有命令:
- host 反覆讀 busy bit,直到變成 clear
- host 設定 write bit,寫入 data-out register
- host 設定 command-ready bit
- controller 看到 command-ready → 設 busy
- controller 執行 I/O,讀 data-out
- controller 清 command-ready 與 error bit,清 busy
Pros / Cons
- 容易浪費 CPU:如果裝置回應慢,CPU 會 busy waiting
- 資料可能丟失:像鍵盤/serial port 若 host 回來太慢會 overflow
高 throughput 時某些 driver 會改用 polling(interrupt overhead 太高),低 throughput 才用 interrupt