2

For example,

in al, 8 

If the device at port 8 is very slow, then does CPU have to wait for completion of the instruction in?

Thanks!

Linuxios
  • 34,849
  • 13
  • 91
  • 116
xmllmx
  • 39,765
  • 26
  • 162
  • 323
  • 3
    No. A driver would only execute this instruction when the device signals that it has data available. – Hans Passant Dec 22 '12 at 18:05
  • How to read the status register? Using another in instruction at another port? That's the same issue. – xmllmx Dec 22 '12 at 18:06
  • @HansPassant: A *good* driver would only do that. A bad one could easily block the kernel siting an waiting for a disk. – Linuxios Dec 22 '12 at 18:07
  • 1
    @xmllmx: No, it's not. A device that takes that long to respond to a status request is a broken device. It doesn't matter how fast a harddrive or CD drive is, the controller should be able to respond fast. – Linuxios Dec 22 '12 at 18:07
  • @Linuxios, Is it correct that a status register at certain port can be regarded as an address of memory? if considering I/O speed only? – xmllmx Dec 22 '12 at 18:12
  • @xmllmx: To be honest, I don't know. But the speed of the underlying storage medium or hardware type should be independent of the controller signaling the CPU that data is available. – Linuxios Dec 22 '12 at 18:13
  • @HansPassant: what would happen if the device responsible for handling a certain PIO address doesn't respond at all to a read request? –  Dec 22 '12 at 18:48
  • 1
    yes, that instruction path stalls until the I/O cycle is complete. early x86 processors the whole thing was stalled, now only one execution unit and any dependencies, so you could craft code that would stall quite a bit of the processor if everyone is dependent on that in instruction. – old_timer Dec 22 '12 at 18:54

1 Answers1

1

It depends on what part of the device is being "really slow". If it takes a lot of time to answer a PIO requests (like in and out), then yes, it will stall the execution unit (and everything that depends on it). The same would happen with "really slow" memory.

However, if the device takes a long time to complete its tasks (whatever they may be), but responds really quickly to PIO requests (e.g. indicating that it hasn't finished a task yet), then it doesn't really stall the CPU.

Properly designed hardware does the latter.