
{"id":6341,"date":"2011-12-02T18:12:47","date_gmt":"2011-12-02T18:12:47","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=6341"},"modified":"2011-12-02T18:12:47","modified_gmt":"2011-12-02T18:12:47","slug":"task_killable","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2011\/12\/02\/task_killable\/","title":{"rendered":"What is a TASK_KILLABLE   state in Linux ?"},"content":{"rendered":"<p><u>ABOUT TASK_KILLABLE state<\/u><\/p>\n<pre>\nTASK_KILLABLE sleeping state.\n\nLike most versions of Unix, Linux has two fundamental ways in which a process  can be put  to sleep. A\nprocess which is placed  in the TASK_INTERRUPTIBLE  state  will sleep  until  either (1)  something\nexplicitly wakes it up, or (2) a non-masked signal is received. The TASK_UNINTERRUPTIBLE state, instead,\nignores signals; processes in that  state will  require an  explicit wakeup  before they  can run\nagain.   There are  advantages and  disadvantages to  each  type of sleep. Interruptible sleeps enable\nfaster response to signals, but they  make   the  programming   harder.  Kernel  code   which  uses\ninterruptible sleeps must always check to see whether it woke up as a result  of a signal, and, if  so,\nclean up whatever  it was doing and return  -EINTR back  to user space.  The user-space  side, too,\nmust  realize  that  a  system  call was  interrupted  and  respond accordingly;  not all  user-space\nprogrammers  are known  for their diligence in this regard. Making a sleep uninterruptible eliminates\nthese problems, but at the cost of being, well, uninterruptible. If the expected  wakeup event does  not\nmaterialize, the  process will wait forever and there is usually nothing that anybody can do about\nit  short  of rebooting  the  system. This  is  the  source of  the dreaded, unkillable process  which is\nshown to be  in the \"D\" state by ps.\n\n\nTASK_KILLABLE behaves like  TASK_UNINTERRUPTIBLE with the exception that fatal signals will interrupt the sleep.\n\n<\/pre>\n<p><u>TYPICAL PART OF A HEADER FILE RELATED (include\/linux\/sched.h)<\/u><br \/>\n[text]<br \/>\n\/* Convenience macros for the sake of set_current_state: *\/<br \/>\n#define TASK_KILLABLE\t\t\t(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)<br \/>\n#define TASK_STOPPED\t\t\t(TASK_WAKEKILL | __TASK_STOPPED)<br \/>\n#define TASK_TRACED\t\t\t(TASK_WAKEKILL | __TASK_TRACED)<\/p>\n<p>#define TASK_IDLE\t\t\t(TASK_UNINTERRUPTIBLE | TASK_NOLOAD)<br \/>\n[\/text]<\/p>\n<p>LINKS<br \/>\n<a href=\"https:\/\/lwn.net\/Articles\/288056\/\">https:\/\/lwn.net\/Articles\/288056\/<\/a><br \/>\n<a href=\"https:\/\/www.ibm.com\/developerworks\/linux\/library\/l-task-killable\/\">https:\/\/www.ibm.com\/developerworks\/linux\/library\/l-task-killable\/<\/a><br \/>\n<a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/ident\/TASK_KILLABLE\">https:\/\/elixir.bootlin.com\/linux\/latest\/ident\/TASK_KILLABLE<\/a><br \/>\n<a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/source\/include\/linux\/sched.h#L90\">https:\/\/elixir.bootlin.com\/linux\/latest\/source\/include\/linux\/sched.h#L90<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ABOUT TASK_KILLABLE state TASK_KILLABLE sleeping state. Like most versions of Unix, Linux has two fundamental ways in which a process can be put to sleep. A process which is placed in the TASK_INTERRUPTIBLE state will sleep until either (1) something explicitly wakes it up, or (2) a non-masked signal is received. The TASK_UNINTERRUPTIBLE state, instead, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2011\/12\/02\/task_killable\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What is a TASK_KILLABLE   state in Linux ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83],"tags":[1454,1487,1547],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/6341"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=6341"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/6341\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=6341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=6341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=6341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}