title: Do we need to call set_current_state(TASK_INTERRUPTIBLE) before calling schedule?
body: <p>Do I need to call <code>set_current_state()</code> before calling <code>schedule()</code> to schedule the next process from the run queue?</p>
  
  <p>I have seen lot of code where the kernel thread function is using <code>set_current_state()</code> to set the state to <code>TASK_RUNNING</code> or <code>TASK_UNINTERRUPTIBLE</code>.</p>
  
  <pre><code>set_current_state(TASK_INTERRUPTIBLE);
  
  while (!kthread_should_stop()) {
          ....
          schedule();
          .....
  }
  __set_current_state(TASK_RUNNING);
  </code></pre>
  
  <p>Is it necessary to call <code>set_current_state()</code> with <code>TASK_INTERRUPTIBLE</code> before calling <code>schedule()</code>?</p>
  
  <p>In this example code, what is the use of setting the state to <code>TASK_RUNNING</code> after it comes out of the <code>kthread_should_stop()</code> loop?</p>