首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | 服务器技术 | linux相关 | linux认证 | 嵌入式 | 下载中心 | 专题 | linux招聘 | 镜像站
OKLinux中文技术站
·设为首页
·加入收藏
·联系我们
系统管理: 中文环境 系统管理 桌面应用 内核技术 | Linux基础: 基础入门 安装配置 常用命令 经验技巧 软件应用 | Linux数据库: Mysql Postgre Oracle DB2 Sybase other
网络管理: 网络安全 网络应用 Linux服务器 环境配置 黑客安全 | 编程开发: PHP CC++ Python Perl Shell 嵌入式开发 java jsp | PHP技术: PHP基础 PHP技巧 PHP应用 PHP文摘
Linux资讯 Linux招聘 Linux专题 Apache | Linux相关: 硬件相关 Linux解决方案 Linux认证 企业应用 其它Unix | 相关下载: 资料下载 参考手册 开发工具 服务器类 软路由 其它
 技术搜索:
会员中心 注册会员 高级搜索  
  → 当前位置:首页>系统管理>内核技术>正文

Linux操作系统的核心数据结构

http://www.oklinux.cn  2007-04-07  来源:           会员收藏  游客收藏  【 】 

本文列出了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 */
  unsigned long rmem_end; /* shmem "recv" end */
  unsigned long rmem_start; /* shmem "recv" start */
  unsigned long mem_end; /* shared mem end */
  unsigned long mem_start; /* shared mem start */
  unsigned long base_addr; /* device I/O address */
  unsigned char irq; /* device IRQ number */
  /* Low-level status flags. */
  volatile unsigned char start, /* start an operation */
  interrupt; /* interrupt arrived */
  unsigned long tbusy; /* transmitter busy */
  struct device *next;
  /* The device initialization function. Called only once. */
  int (*init)(struct device *dev);
  /* Some hardware also needs these fields, but they are not part of
  the usual set specified in Space.c. */
  unsigned char if_port; /* Selectable AUI,TP, */
  unsigned char dma; /* DMA channel */
  struct enet_statistics* (*get_stats)(struct device *dev);
  /*
  * This marks the end of the "visible" part of the structure. All
  * fields hereafter are internal to the system, and may change at
  * will (read: may be cleaned up at will).
  */
  /* These may be needed for future network-power-down code. */
  unsigned long trans_start; /* Time (jiffies) of last transmit */
  unsigned long last_rx; /* Time of last Rx */
  unsigned short flags; /* interface flags (BSD)*/
  unsigned short family; /* address family ID */
  unsigned short metric; /* routing metric */
  unsigned short mtu; /* MTU value */
  unsigned short type; /* hardware type */
  unsigned short hard_header_len; /* hardware hdr len */
  void *priv; /* private data */
  /* Interface address info. */
  unsigned char broadcast[MAX_ADDR_LEN];
  unsigned char pad;
  unsigned char dev_addr[MAX_ADDR_LEN];
  unsigned char addr_len; /* hardware addr len */
  unsigned long pa_addr; /* protocol address */
  unsigned long pa_brdaddr; /* protocol broadcast addr*/
  unsigned long pa_dstaddr; /* protocol P-P other addr*/
  unsigned long pa_mask; /* protocol netmask */
  unsigned short pa_alen; /* protocol address len */
  struct dev_mc_list *mc_list; /* M'cast mac addrs */
  int mc_count; /* No installed mcasts */
  struct ip_mc_list *ip_mc_list; /* IP m'cast filter chain */
  __u32 tx_queue_len; /* Max frames per queue */
  /* For load balancing driver pair support */
  unsigned long pkt_queue; /* Packets queued */
  struct device *slave; /* Slave device */
  struct net_alias_info *alias_info; /* main dev alias info */
  struct net_alias *my_alias; /* alias devs */
  /* Pointer to the interface buffers. */
  struct sk_buff_head buffs[DEV_NUMBUFFS];
  /* Pointers to interface service routines. */
  int (*open)(struct device *dev);
  int (*stop)(struct device *dev);
  int (*hard_start_xmit) (struct sk_buff *skb,
  struct device *dev);
  int (*hard_header) (struct sk_buff *skb,
  struct device *dev,
  unsigned short type,
  void *daddr,
  void *saddr,
  unsigned len);
  int (*rebuild_header)(void *eth,
  struct device *dev,
  unsigned long raddr,
  struct sk_buff *skb);
  void (*set_multicast_list)(struct device *dev);
  int (*set_mac_address)(struct device *dev,
  void *addr);
  int (*do_ioctl)(struct device *dev,
  struct ifreq *ifr,
  int cmd);
  int (*set_config)(struct device *dev,
  struct ifmap *map);
  void (*header_cache_bind)(struct hh_cache **hhp,
  struct device *dev,
  unsigned short htype,
  __u32 daddr);
  void (*header_cache_update)(struct hh_cache *hh,
  struct device *dev,
  unsigned char * haddr);
  int (*change_mtu)(struct device *dev,
  int new_mtu);
  struct iw_statistics* (*get_wireless_stats)(struct device *dev);
  };
  device_struct

此结构被块设备和字符设备用来向核心登记(包含设备名称以及可对此设备进行的文件操作)。chrdevs和blkdevs中的每个有效分别表示一个字符设备和块设备。

共2页: 上一页 1 [2] 下一页

上一篇: Linux下通用线程池的创建与使用(上)   下一篇: 如何编译一个Linux操作系统内核-Ubuntu方式


收藏于收藏夹】 【评论】 【推荐】 【打印】 【关闭
相关文档
· 如何编译一个Linux操作系统内核-Ubuntu方式
· Linux下通用线程池的创建与使用(上)
· THE LINUX/I386 BOOT PROTOCOL
· Linux下通用线程池的创建与使用(下)
· Linux系统内核代码特色一览
· Linux的系统过程中的LILO和GRUB(上)
· Linux系统中使用SystemTap调试内核
· Linux 内核解读入门
· Linux操作系统内核等待队列机制介
· Linux系统下解析Elf文件DT_RPATH后门
· Linux系统内核的同步机制“自旋锁”
· 小型的集成开源操作系统DSL Linux
· linux2.6内核编译
· Linux 2.6.11内核文件IO系统调用详解
· Linux的NAPI和Solaris的GLDv3
· Linux重新编译内核指南
发表评论
密码: 匿名评论
评论内容:

(不超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
 
  最新文档
·学习园地:Linux系统内核中判断大小的
·系统编译:如何给Make命令来传递参数
·Linux 2.6内核中sysfs文件系统简单概述
·Fedora 8 Linux系统的内核配置注意事项
·升级Linux内核的一般步骤方法
·Linux发行版知识普及:三个版本的CPUID
·编译安装Virtualbox驱动模块
· Linux系统的内核解读入门
·新手学堂 Linux系统的内核解读入门
·Linux系统内核中网络参数的意义及其应
·走向Linux系统高手之路 内核编译过程解
·Linux系统中安装内核的方法详细介绍
  阅读排行
· 深入理解LINUX内核中文版下载地址
·基于S3C44B0微处理器的uClinux内核引导
·Kernel command using Linux system ca
·Linux 2.6内核如何武装Fedora Core 2
·Process priority and control on AIX
·Linux操作系统的内核编译内幕详解
·推荐:Linux用户态与内核态的交互
·通过振动向Linux ThinkPad传输信息
·Linux操作系统源代码详细分析(二)
·Linux系统内核接收以太帧的处理程序
·Linux and symmetric multiprocessing
·主流嵌入式Linux系统下GUI解决方案
·揭秘Linux内核调试器之内幕
·用命令行加挂Linux的文件系统简介
·Linux内核和核心OS组件的测试与分析
网摘收藏: