内核线程中的set\u current\u state()宏是什么?

内核线程中的set\u current\u state()宏是什么?,c,linux,linux-kernel,linux-device-driver,C,Linux,Linux Kernel,Linux Device Driver,在研究内核线程时,我遇到了这段代码 while(!kthread_should_stop()){ set_current_state(TASK_RUNNING); /* Doing some stuff here */ set_current_state(TASK_INTERRUPTIBLE); msleep(1000); 宏设置当前状态用于什么,传递的参数是什么。根据本文 set\u current\u state()将当前正在执行的进程的状态从TASK\u RU

在研究内核线程时,我遇到了这段代码

while(!kthread_should_stop()){ 
  set_current_state(TASK_RUNNING);

  /* Doing some stuff here */

  set_current_state(TASK_INTERRUPTIBLE);
  msleep(1000);   
宏设置当前状态用于什么,传递的参数是什么。

根据本文

set\u current\u state()
将当前正在执行的进程的状态从
TASK\u RUNNING
更改为
TASK\u interruptable

这里,
TASK\u RUNNING
TASK\u interruptable
是进程的两种状态

  • TASK\u RUNNING
    ——准备运行的进程的状态为TASK\u RUNNING
  • TASK\u interruptable
    ——调用进程的状态为
    schedule()
    ,进程从运行队列中移出
根据本文

set\u current\u state()
将当前正在执行的进程的状态从
TASK\u RUNNING
更改为
TASK\u interruptable

这里,
TASK\u RUNNING
TASK\u interruptable
是进程的两种状态

  • TASK\u RUNNING
    ——准备运行的进程的状态为TASK\u RUNNING
  • TASK\u interruptable
    ——调用进程的状态为
    schedule()
    ,进程从运行队列中移出