Linux core-16. Linux data structure

Source: Internet
Author: User
Article title: Linux core-16. Linux data structure. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Original: David A Rusling
Translation: Banyan & fifa
  
Chapter 2 Linux core data structure
  
This chapter lists the main practical data structures of Linux.
Block_dev_struct
This structure is used to register the block device to the core. it is also used by the buffer cache. All such structures are in the blk_dev array.
  
Struct blk_dev_struct {
Void (* request_fn) (void );
Struct request * current_request;
Struct request plug;
Struct tq_struct plug_tq;
};
  
Buffer_head
This structure contains information about a 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 (abve )*/
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
* Shoshould 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
Each network device in the system is represented by a device data structure.
  
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
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
* Will (read: may be cleaned up at will ).
*/
  
/* These may be needed for future network-power-down code .*/
Unsigned long trans_start;/* Time (jiffies)
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.