Why doing I/O in Linux is uninterruptible?

后端 未结 2 1848
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 02:44

What\'s the rationale behind it? What would the bad consequences be if a process doing I/O is allowed to handle signal?

2条回答
  •  臣服心动
    2020-12-11 03:24

    Now that I've read the book "The Design of the Unix Operating Systems" by Maurice Bach, let me answer this question by myself.

    In short, making I/O uninterruptible is for the purpose of making the I/O task finish ASAP, without being interfered by signals.

    Some related knowledge that I gained from the book:

    1. The word "uninterruptible" should refer to "uninterruptible sleep". When a process is in uninterruptible sleep, it can NOT be waked up by signals, nor would it handle signals.
    2. A process handles signals when: a. it is running in kernel mode and is about to return to the user mode. b. it is about to enter and leave sleep state when the sleep is interruptible.
    3. What happens when a sleeping process is waken up by a signal? It would handle the signal, with the default action being exiting the process. When a process is waiting for I/O completion, you of course do not want it to exit prematurely.

提交回复
热议问题