Linux 核心--16.Linux数据结构

2016-01-29 19:42 4 1 收藏

Linux 核心--16.Linux数据结构,Linux 核心--16.Linux数据结构

【 tulaoshi.com - Linux 】

  第十五章 Linux核心数据结构 

本章列出了Linux实用的主要数据结构。 


block_dev_struct
此结构用于向核心登记块设备,它还被buffer cache实用。所有此类结构都位于blk_dev数组中。 

struct blk_dev_struct {
    void (*request_fn)(void);
    struct request * current_request;
    struct request   plug;
    struct tq_struct plug_tq;
};

buffer_head
此结构包含关于buffer cache中一块缓存的信息。 

/* bh state bits */
#define BH_Uptodate  0   /* 1 if the buffer contains valid data      */
#define BH_Dirty     1   /* 1 if the buffer is dirty                 */
#define BH_Lock      2   /* 1 if the buffer is locked                */
#define BH_Req       3   /* 0 if the buffer has been invalidated     */
#define BH_Touched   4   /* 1 if the buffer has been touched (aging) */
#define BH_Has_aged  5   /* 1 if the buffer has been aged (aging)    */
#define BH_Protected 6   /* 1 if the buffer is protected             */
#define BH_FreeOnIO  7   /* 1 to discard the buffer_head after IO    */

struct buffer_head {
  /* First cache line: */
  unsigned long      b_blocknr;    /* block number                   */
  kdev_t             b_dev;        /* device (B_FREE = free)         */
  kdev_t             b_rdev;       /* Real device                    */
  unsigned long      b_rsector;    /* Real buffer location on disk   */
  struct buffer_head *b_next;      /* Hash queue list                */
  struct buffer_head *b_this_page; /* circular list of buffers in one 
                                      page                           */

  /* Second cache line: */
  unsigned long      b_state;      /* buffer state bitmap (above)    */
  struct buffer_head *b_next_free;
  unsigned int       b_count;      /* users using this block         */
  unsigned long      b_size;       /* block size                     */

  /* Non-performance-critical data follows. */
  char               *b_data;      /* pointer to data block          */
  unsigned int       b_list;       /* List that this buffer appears  */
  unsigned long      b_flushtime;  /* Time when this (dirty) buffer
                                    * should be written              */
  unsigned long      b_lru_time;   /* Time when this buffer was 
                                    * last used.                     */
  struct wait_queue  *b_wait;
  struct buffer_head *b_prev;      /* doubly linked hash list        */
  struct buffer_head *b_prev_free; /* doubly linked list of buffers  */
  struct buffer_head *b_reqnext;   /* request queue                  */
};

device
系统中每个网络设备都用一个设备数据结构来表示。 

struct device 
{

  /*
   * This is the first field of the "visible" part of this structure
   * (i.e. as seen by users in the "Space.c" file).  It is the name
   * the interface.
   */
  char                    *name;

  /* I/O specific fields

来源:https://www.tulaoshi.com/n/20160129/1509949.html

延伸阅读
  原著: David A Rusling 翻译: Banyan & fifa -------------------------------------------------------------------------------- 本书是为那些想了解Linux内核工作原理的Linux狂热爱好者而写。 它并非一本内部手册。主要描叙了Linux设计的原理与机制;以及Linux内核怎样工作及其原因。 Linux...
  第三章 存储管理 存储管理子系统时操作系统中最重要的组成部分之一。在早期计算时代,由于人们所需要的内存数目远远大于物理内存,人们设计出了各种各样的策略来解决此问题,其中最成功的是虚拟内存技术。它使得系统中为有限物理内存竞争的进程所需内存空间得到满足。 虚拟内存技术不仅仅可让我们可以使用更多的内存,它还提供了...
3. 把中缀表达式转换为后缀表达式的算法     设以’@’字符作为结束符的中缀算术表达式已经保存在s1字符串中,转换后得到的后缀算术表达式拟存于s2字符串中。由中缀表达式转换为后缀表达式的规则可知:转换前后,表达式中的数值项的次序不变,而运算符的次序发生了变化,由处在两个运算对象的中间变为处在两个运算对象的后面...
  第一章 硬件基础 操作系统必须与基本硬件系统密切协作。它需要那些仅仅能够由硬件提供的服务。为了全面理解Linux操作系统,你必须要懂得一些有关硬件的知识。本章将对硬件:现代PC做一个简要的介绍。 当1975年一月的"Popular Electronics"杂志以Altair 8080的图片作为封面时,一场革命开始了。 家用电器爱好者能独立组装出来的A...
  第八章 设备驱动 操作系统的目的之一就是将系统硬件设备细节从用户视线中隐藏起来。例如虚拟文件系统对各种类型已安装的文件系统提供了统一的视图而屏蔽了具体底层细节。本章将描叙Linux核心对系统中物理设备的管理。 CPU并不是系统中唯一的智能设备,每个物理设备都拥有自己的控制器。键盘、鼠标和串行口由一个高级I/O芯片统一...

经验教程

780

收藏

32
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部