linux - TASK_KILLABLE 和 TASK_INTERRUPTIBLE 有什么区别?

标签 linux linux-kernel

TASK_KILLABLE 似乎应该是 TASK_INTERRUPTIBLE 的一个子集,因为终止任务是,嗯,中断它的一种方式;然而,根据 sched.h herehere看起来 TASK_KILLABLE 是 UNINTERRUPTIBLE。

#define TASK_INTERRUPTIBLE      1
#define TASK_UNINTERRUPTIBLE    2
#define TASK_WAKEKILL           128
#define TASK_KILLABLE           (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)

这对我来说真正归结为;我什么时候想使用 wait_for_completion_interruptible_timeoutwait_for_completion_killable_timeout

最佳答案

事实证明,更多的搜索为我找到了答案:articlethis somewhat related answer 中引用状态:

Kernel code which uses interruptible sleeps must always check to see whether it woke up as a result of a signal, and, if so, clean up whatever it was doing and return -EINTR back to user space. The user-space side, too, must realize that a system call was interrupted and respond accordingly; not all user-space programmers are known for their diligence in this regard.

many of these concerns about application bugs do not really apply if the application is about to be killed anyway. It does not matter if the developer thought about the possibility of an interrupted system call if said system call is doomed to never return to user space. So Matthew created a new sleeping state, called TASK_KILLABLE; it behaves like TASK_UNINTERRUPTIBLE with the exception that fatal signals will interrupt the sleep

关于linux - TASK_KILLABLE 和 TASK_INTERRUPTIBLE 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27002488/

相关文章:

linux - Csh 脚本等待多个 pid

linux - 无法从 atd 运行 X11(图形)程序

assembly - 在arm64汇编中, "adrp x0, idmap_pg_dir;"指令是什么意思?

c - execv()系统调用中一段代码的含义

linux - 如何在树中导入树外的git历史

c++ - gcc 编译器报告类的大小=零

linux - Qt 应用程序 GUI -- 自动启动 -- linux

Javascript读取本地文件适用于Windows但不适用于Linux

linux-kernel - 交叉编译 Linux 内核模块

linux - 如何在 exit() 系统调用中调用我自己的系统调用