线程状态与tcb、线程的生命周期

struct tcb {
  u32_t status;
  struct reg_context thread_context;
  void *stack;
  struct thread_info thread_params;
  u32_t executedTime;
  struct tcb *recoveryTask;
  u32_t sched_field;
  u32_t magic_key;
};

阻塞状态(Blocked)

        线程运行过程中,可能由于各种原因进入阻塞状态:
        1>线程通过调用sleep方法进入睡眠状态;
        2>线程调用一个在I/O上被阻塞的操作,即该操作在输入输出操作完成之前不会返回到它的调用者;
        3>线程试图得到一个锁,而该锁正被其他线程持有;
        4>线程在等待某个触发条件;
        ......           

        所谓阻塞状态是正在运行的线程没有运行结束,暂时让出CPU,这时其他处于就绪状态的线程就可以获得CPU时间,进入运行状态。

原文地址:https://www.cnblogs.com/feng9exe/p/8337296.html