Polling

Handshaking

controller 用 busy bit 表示狀態,host 用 command-ready bit 表示有命令:

  1. host 反覆讀 busy bit,直到變成 clear
  2. host 設定 write bit,寫入 data-out register
  3. host 設定 command-ready bit
  4. controller 看到 command-ready → 設 busy
  5. controller 執行 I/O,讀 data-out
  6. controller 清 command-ready 與 error bit,清 busy

Pros / Cons

  • 容易浪費 CPU:如果裝置回應慢,CPU 會 busy waiting
  • 資料可能丟失:像鍵盤/serial port 若 host 回來太慢會 overflow

高 throughput 時某些 driver 會改用 polling(interrupt overhead 太高),低 throughput 才用 interrupt