In man 7 signal, it describes certain constraints regarding when the SA_RESTART flag takes effect.
read(2), readv(2), write(2), writev(2), and ioctl(2) calls on "slow" devices. A "slow" device is one where the I/O call may block for an indefinite time, for example, a terminal, pipe, or socket. If an I/O call on a slow device has already transferred some data by the time it is interrupted by a signal handler, then the call will return a success status (normally, the number of bytes transferred). Note that a (local) disk is not a slow device according to this definition; I/O operations on disk devices are not interrupted by signals.
My questions are
Thanks.
The answer is simpler to understand than the manual.
A "slow" device is one for which the device driver can be interrupted by a signal.
Most device drivers can be interrupted. The block drivers can't.
For the other devices you list, network devices are character devices and must be interruptible. (A packet driver can only interrupt between packets but that's not really relevant as you can't receive half a packet over the wire...) As for a GPU or ASIC accelerator I'd have to literally open up the driver and check, but if I had to guess I'd guess they aren't slow devices, because somebody would have to bother to implement the ability to interrupt and didn't because those devices are faster than the disk.
Block device being non-interruptable can be painful when it's waiting for a scratched CD-ROM but that's nothing compaired to a device that could theoretically wait forever.
It's difficult for me to judge according to the property "indefinite time".
A slow device is one device in which the termination (the interrupt signalling that data is available and the user process can be awakened) is not warranted to happen in a bounded time. For example, a disk is not a slow device, because the interrupt signalling the data transfer is warranted to occur in a short time (normally a disk data transfer is scheduled to be handled by a DMA channel, and the waiting process is awakened as soon as the transfer is finished). In case you wait for a slow device, you can be delayed, but you will get the data you requested in a short time (this happens reading a file, for example, but you can be waiting for a user to input data on a terminal for years :) ) A network device is slow, as you can wait forever for communication to start/continue/finish.
Think on this: If you ask the device for data, and the device cannot awaken your process until the data is ready, how long can you wait for the data to be available? If you cannot say a bound, then the device is slow (probably indeterminate is not the best word, but unbounded would have been better) if you can say that the device will allow your process to continue in a maximum but bounded time, (depending on the device) then the device is considered fast. Fast devices sleep in a non interruptable way (you cannot interrupt it until the device finishes the data transfer) while interruptable devices will return -1 and you will get EAGAIN
error.
The kernel treats them differently, as a disk operation will not be interrupted while waiting for the data to arrive, as the whole operation to the disk would have to be cancelled. A process waiting for disk I/O will never be interrupted (even if you SIGKILL
it) until the data transfer is finished. The signal will have to finish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With