zoukankan      html  css  js  c++  java
  • Thread Control Block

    Thread Control Block

    The following is the declaration of the Thread Control Block.

    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;
    };
    
    • unsigned int status

      This field holds the status information of the current thread. It can be one of THREAD_ON_CPU, THREAD_READY, THREAD_SUSPENDED THREAD_BLOCKED, THREAD_EXITED or THREAD_MISSED_DEADLINE. 

      This field is not directly updated by the kernel. The kernel thread library informs the scheduler about the status of a thread through the Scheduler API. It is upto the scheduler object to keep this field consistent. For example when a thread exits, the kernel calls the function set_mode(curr_thread,THREAD_EXITED) of the scheduler API. This approach of calling a scheduler function to update the status helps, when the sheduler needs to do additional work (apart from setting it's status) whenever the status of a thread changes. For example, for periodic threads, it might reset them when they exit. 

    • struct reg_context thread_context

      This structure stores the context of a thread. The structure reg_context is architecture specific. This field is accessed by the kernel thread library only. (The scheduler object should not mess with it).

    • struct thread_info thread_params

      This field holds the initial thread parameters, like the start function, stack size, deadline etc. This information is required for resetting threads.

    • void * stack

      This field is a pointer to the stack of the thread.

    • u32_t executedTime

      This field can be used for keeping profiling information for the thread. This is currently not being used.

    • u32_t sched_field

      This field is meant for use by the scheduler object. The kernel never accessed this field. 

      Typically this field will be used by the scheduler object for constructing datastructure of tcb's. For example if the scheduler object stores the ready threads in a list, this field would be used as next pointer.

    • u32_t magic_key

      This field is used for debugging and should go away in the final release.

    http://www.cse.iitd.ernet.in/~soumyadeb/projects/mtp/report/node56.html

  • 相关阅读:
    使用TransactionScope实现多数据库连接事务操作
    zabbix_agentlinux下的安装
    (转)Zabbix AgentWindows平台配置指导
    使用SpringSide 3.1.4.3开发Web项目的全过程(上)
    应用开发中数据字典项设计实现方案
    Oracle Top N 和 Oracle中的limit问题解决方案
    Struts 2.0的codebehinde插件应用简述
    PropertyUtils和MethodUtils使用
    Log4j基本使用方法
    Quartz从入门到进阶
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8336748.html
Copyright © 2011-2022 走看看