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

资讯 驱动中国 1,564 次阅读 0 条评论
分享 Q

第十五章Linux核心数据结构

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


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

structblk_dev_struct{
void(*request_fn)(void);
structrequest*current_request;
structrequestplug;
structtq_structplug_tq;
};

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

/*bhstatebits*/
#defineBH_Uptodate0/*1ifthebuffercontainsvaliddata*/
#defineBH_Dirty1/*1ifthebufferisdirty*/
#defineBH_Lock2/*1ifthebufferislocked*/
#defineBH_Req3/*0ifthebufferhasbeeninvalidated*/
#defineBH_Touched4/*1ifthebufferhasbeentouched(aging)*/
#defineBH_Has_aged5/*1ifthebufferhasbeenaged(aging)*/
#defineBH_Protected6/*1ifthebufferisprotected*/
#defineBH_FreeOnIO7/*1todiscardthebuffer_headafterIO*/

structbuffer_head{
/*Firstcacheline:*/
unsignedlongb_blocknr;/*blocknumber*/
kdev_tb_dev;/*device(B_FREE=free)*/
kdev_tb_rdev;/*Realdevice*/
unsignedlongb_rsector;/*Realbufferlocationondisk*/
structbuffer_head*b_next;/*Hashqueuelist*/
structbuffer_head*b_this_page;/*circularlistofbuffersinone
page*/

/*Secondcacheline:*/
unsignedlongb_state;/*bufferstatebitmap(above)*/
structbuffer_head*b_next_free;
unsignedintb_count;/*usersusingthisblock*/
unsignedlongb_size;/*blocksize*/

/*Non-performance-criticaldatafollows.*/
char*b_data;/*pointertodatablock*/
unsignedintb_list;/*Listthatthisbufferappears*/
unsignedlongb_flushtime;/*Timewhenthis(dirty)buffer
*shouldbewritten*/
unsignedlongb_lru_time;/*Timewhenthisbufferwas
*lastused.*/
structwait_queue*b_wait;
structbuffer_head*b_prev;/*doublylinkedhashlist*/
structbuffer_head*b_prev_free;/*doublylinkedlistofbuffers*/
structbuffer_head*b_reqnext;/*requestqueue*/
};

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

structdevice
{

/*
*Thisisthefirstfieldofthe"visible"partofthisstructure
*(i.e.asseenbyusersinthe"Space.c"file).Itisthename
*theinterface.
*/
char*name;

/*I/Ospecificfields*/
unsignedlongrmem_end;/*shmem"recv"end*/
unsignedlongrmem_start;/*shmem"recv"start*/
unsignedlongmem_end;/*sharedmemend*/
unsignedlongmem_start;/*sharedmemstart*/
unsignedlongbase_addr;/*deviceI/Oaddress*/
unsignedcharirq;/*deviceIRQnumber*/

/*Low-levelstatusflags.*/
volatileunsignedcharstart,/*startanoperation*/
interrupt;/*interruptarrived*/
unsignedlongtbusy;/*transmitterbusy*/
structdevice*next;

/*Thedeviceinitializationfunction.Calledonlyonce.*/
int(*init)(structdevice*dev);

/*Somehardwarealsoneedsthesefields,buttheyarenotpartof
theusualsetspecifiedinSpace.c.*/
unsignedcharif_port;/*SelectableAUI,TP,*/
unsignedchardma;/*DMAchannel*/

structenet_statistics*(*get_stats)(structdevice*dev);

/*
*Thismarkstheendofthe"visible"partofthestructure.All
*fieldshereafterareinternaltothesystem,andmaychangeat
*will(read:maybecleanedupatwill).
*/

/*Thesemaybeneededforfuturenetwork-power-downcode.*/
unsignedlongtrans_start;/*Time(jiffies)of
lasttransmit*/
unsignedlonglast_rx;/*TimeoflastRx*/
unsignedshortflags;/*interfaceflags(BSD)*/
unsignedshortfamily;/*addressfamilyID*/
unsignedshortmetric;/*routingmetric*/
unsignedshortmtu;/*MTUvalue*/
unsignedshorttype;/*hardwaretype*/
unsignedshorthard_header_len;/*hardwarehdrlen*/
void*priv;/*privatedata*/

/*Interfaceaddressinfo.*/
unsignedcharbroadcast[MAX_ADDR_LEN];
unsignedcharpad;
unsignedchardev_addr[MAX_ADDR_LEN];
unsignedcharaddr_len;/*hardwareaddrlen*/
unsignedlongpa_addr;/*protocoladdress*/
unsignedlongpa_brdaddr;/*protocolbroadcastaddr*/
unsignedlongpa_dstaddr;/*protocolP-Potheraddr*/
unsignedlongpa_mask;/*protocolnetmask*/
unsignedshortpa_alen;/*protocoladdresslen*/

structdev_mc_list*mc_list;/*M'castmacaddrs*/
intmc_count;/*Noinstalledmcasts*/

structip_mc_list*ip_mc_list;/*IPm'castfilterchain*/
__u32tx_queue_len;/*Maxframesperqueue*/

/*Forloadbalancingdriverpairsupport*/
unsignedlongpkt_queue;/*Packetsqueued*/
structdevice*slave;/*Slavedevice*/
structnet_alias_info*alias_info;/*maindevaliasinfo*/
structnet_alias*my_alias;/*aliasdevs*/

/*Pointertotheinterfacebuffers.*/
structsk_buff_headbuffs[DEV_NUMBUFFS];

/*Pointerstointerfaceserviceroutines.*/
int(*open)(structdevice*dev);
int(*stop)(structdevice*dev);
int(*hard_start_xmit)(structsk_buff*skb,
structdevice*dev);
int(*hard_header)(structsk_buff*skb,
structdevice*dev,
unsignedshorttype,
void*daddr,
void*saddr,
unsignedlen);
int(*rebuild_header)(void*eth,
structdevice*dev,
unsignedlongraddr,
structsk_buff*skb);
void(*set_multicast_list)(structdevice*dev);
int(*set_mac_address)(structdevice*dev,
void*addr);
int(*do_ioctl)(structdevice*dev,
structifreq*ifr,
intcmd);
int(*set_config)(structdevice*dev,
structifmap*map);
void(*header_cache_bind)(structhh_cache**hhp,
structdevice*dev,
unsignedshorthtype,
__u32daddr);
void(*header_cache_update)(structhh_cache*hh,
structdevice*dev,
unsignedchar*haddr);
int(*change_mtu)(structdevice*dev,
intnew_mtu);
structiw_statistics*(*get_wireless_stats)(structdevice*dev);
};

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

structdevice_struct{
constchar*name;
structfile_operations*fops;
};

file
每个打开的文件、套接口都用此结构表示。

structfile{
mode_tf_mode;
loff_tf_pos;
unsignedshortf_flags;
unsignedshortf_count;
unsignedlongf_reada,f_ramax,f_raend,f_ralen,f_rawin;
structfile*f_next,*f_prev;
intf_owner;/*pidor-pgrpwhereSIGIOshouldbesent*/
structinode*f_inode;
structfile_operations*f_op;
unsignedlongf_version;
void*private_data;/*neededforttydriver,andmaybeothers*/
};

files_struct
描叙被某进程打开的所有文件。

structfiles_struct{
intcount;
fd_setclose_on_exec;
fd_setopen_fds;
structfile*fd[NR_OPEN];
};

fs_struct

structfs_struct{
intcount;
unsignedshortumask;
structinode*root,*pwd;
};

gendisk
包含关于某个硬盘的信息。用于磁盘初始化与分区检查时。

structhd_struct{
longstart_sect;
longnr_sects;
};

structgendisk{
intmajor;/*majornumberofdriver*/
constchar*major_name;/*nameofmajordriver*/
intminor_shift;/*numberoftimesminorisshiftedto
getrealminor*/
intmax_p;/*maximumpartitionsperdevice*/
intmax_nr;/*maximumnumberofrealdevices*/

void(*init)(structgendisk*);
/*Initializationcalledbeforewe
doourthing*/
structhd_struct*part;/*partitiontable*/
int*sizes;/*devicesizeinblocks,copiedto
blk_size[]*/
intnr_real;/*numberofrealdevices*/

void*real_devices;/*internaluse*/
structgendisk*next;
};

inode
此VFSinode结构描叙磁盘上一个文件或目录的信息。

structinode{
kdev_ti_dev;
unsignedlongi_ino;
umode_ti_mode;
nlink_ti_nlink;
uid_ti_uid;
gid_ti_gid;
kdev_ti_rdev;
off_ti_size;
time_ti_atime;
time_ti_mtime;
time_ti_ctime;
unsignedlongi_blksize;
unsignedlongi_blocks;
unsignedlongi_version;
unsignedlongi_nrpages;
structsemaphorei_sem;
structinode_operations*i_op;
structsuper_block*i_sb;
structwait_queue*i_wait;
structfile_lock*i_flock;
structvm_area_struct*i_mmap;
structpage*i_pages;
structdquot*i_dquot[MAXQUOTAS];
structinode*i_next,*i_prev;
structinode*i_hash_next,*i_hash_prev;
structinode*i_bound_to,*i_bound_by;
structinode*i_mount;
unsignedshorti_count;
unsignedshorti_flags;
unsignedchari_lock;
unsignedchari_dirt;
unsignedchari_pipe;
unsignedchari_sock;
unsignedchari_seek;
unsignedchari_update;
unsignedshorti_writecount;
union{
structpipe_inode_infopipe_i;
structminix_inode_infominix_i;
structext_inode_infoext_i;
structext2_inode_infoext2_i;
structhpfs_inode_infohpfs_i;
structmsdos_inode_infomsdos_i;
structumsdos_inode_infoumsdos_i;
structiso_inode_infoisofs_i;
structnfs_inode_infonfs_i;
structxiafs_inode_infoxiafs_i;
structsysv_inode_infosysv_i;
structaffs_inode_infoaffs_i;
structufs_inode_infoufs_i;
structsocketsocket_i;
void*generic_ip;
}u;
};

ipc_perm
此结构描叙对一个系统VIPC对象的存取权限。

structipc_perm
{
key_tkey;
ushortuid;/*ownereuidandegid*/
ushortgid;
ushortcuid;/*creatoreuidandegid*/
ushortcgid;
ushortmode;/*accessmodesseemodeflagsbelow*/
ushortseq;/*sequencenumber*/
};

irqaction
用来描叙系统的中断处理过程。

structirqaction{
void(*handler)(int,void*,structpt_regs*);
unsignedlongflags;
unsignedlongmask;
constchar*name;
void*dev_id;
structirqaction*next;
};

linux_binfmt
用来表示可被Linux理解的二进制文件格式。

structlinux_binfmt{
structlinux_binfmt*next;
long*use_count;
int(*load_binary)(structlinux_binprm*,structpt_regs*regs);
int(*load_shlib)(intfd);
int(*core_dump)(longsignr,structpt_regs*regs);
};

mem_map_t
用来保存每个物理页面的信息。

typedefstructpage{
/*thesemustbefirst(freeareahandling)*/
structpage*next;
structpage*prev;
structinode*inode;
unsignedlongoffset;
structpage*next_hash;
atomic_tcount;
unsignedflags;/*atomicflags,somepossibly
updatedasynchronously*/
unsigneddirty:16,
age:8;
structwait_queue*wait;
structpage*prev_hash;
structbuffer_head*buffers;
unsignedlongswap_unlock_entry;
unsignedlongmap_nr;/*page->map_nr==page-mem_map*/
}mem_map_t;

mm_struct
用来描叙某任务或进程的虚拟内存。

structmm_struct{
intcount;
pgd_t*pgd;
unsignedlongcontext;
unsignedlongstart_code,end_code,start_data,end_data;
unsignedlongstart_brk,brk,start_stack,start_mmap;
unsignedlongarg_start,arg_end,env_start,env_end;
unsignedlongrss,total_vm,locked_vm;
unsignedlongdef_flags;
structvm_area_struct*mmap;
structvm_area_struct*mmap_avl;
structsemaphoremmap_sem;
};

pci_bus
表示系统中的一个PCI总线。

structpci_bus{
structpci_bus*parent;/*parentbusthisbridgeison*/
structpci_bus*children;/*chainofP2Pbridgesonthisbus*/
structpci_bus*next;/*chainofallPCIbuses*/

structpci_dev*self;/*bridgedeviceasseenbyparent*/
structpci_dev*devices;/*devicesbehindthisbridge*/

void*sysdata;/*hookforsys-specificextension*/

unsignedcharnumber;/*busnumber*/
unsignedcharprimary;/*numberofprimarybridge*/
unsignedcharsecondary;/*numberofsecondarybridge*/
unsignedcharsubordinate;/*maxnumberofsubordinatebuses*/
};

pci_dev
表示系统中的每个PCI设备,包括PCI-PCI和PCI-PCI桥接器。

/*
*Thereisonepci_devstructureforeachslot-number/function-number
*combination:
*/
structpci_dev{
structpci_bus*bus;/*busthisdeviceison*/
structpci_dev*sibling;/*nextdeviceonthisbus*/
structpci_dev*next;/*chainofalldevices*/

void*sysdata;/*hookforsys-specificextension*/

unsignedintdevfn;/*encodeddevice&functionindex*/
unsignedshortvendor;
unsignedshortdevice;
unsignedintclass;/*3bytes:(base,sub,prog-if)*/
unsignedintmaster:1;/*setifdeviceismastercapable*/
/*
*Intheory,theirqlevelcanbereadfromconfiguration
*spaceandallwouldbefine.However,oldPCIchipsdon't
*supporttheseregistersandreturn0instead.Forexample,
*theVision864-Prev0chipcanusesINTA,butreturns0in
*theinterruptlineandpinregisters.pci_init()
*initializesthisfieldwiththevalueatPCI_INTERRUPT_LINE
*anditisthejobofpcibios_fixup()tochangeitif
*necessary.Thefieldmustnotbe0unlessthedevice
*cannotgenerateinterruptsatall.
*/
unsignedcharirq;/*irqgeneratedbythisdevice*/
};

request
被用来向系统的块设备发送请求。它总是向buffercache读出或写入数据块。

structrequest{
volatileintrq_status;
#defineRQ_INACTIVE(-1)
#defineRQ_ACTIVE1
#defineRQ_SCSI_BUSY0xffff
#defineRQ_SCSI_DONE0xfffe
#defineRQ_SCSI_DISCONNECTING0xffe0

kdev_trq_dev;
intcmd;/*READorWRITE*/
interrors;
unsignedlongsector;
unsignedlongnr_sectors;
unsignedlongcurrent_nr_sectors;
char*buffer;
structsemaphore*sem;
structbuffer_head*bh;
structbuffer_head*bhtail;
structrequest*next;
};

rtable
用来描叙向某个IP主机发送包的路由信息。此结构在IP路由cache内部实用。

structrtable
{
structrtable*rt_next;
__u32rt_dst;
__u32rt_src;
__u32rt_gateway;
atomic_trt_refcnt;
atomic_trt_use;
unsignedlongrt_window;
atomic_trt_lastuse;
structhh_cache*rt_hh;
structdevice*rt_dev;
unsignedshortrt_flags;
unsignedshortrt_mtu;
unsignedshortrt_irtt;
unsignedcharrt_tos;
};

semaphore
保护临界区数据结构和代码信号灯。

structsemaphore{
intcount;
intwaking;
intlock;/*tomakewakingtestingatomic*/
structwait_queue*wait;
};

sk_buff
用来描叙在协议层之间交换的网络数据。

structsk_buff
{
structsk_buff*next;/*Nextbufferinlist*/
structsk_buff*prev;/*Previousbufferinlist*/
structsk_buff_head*list;/*Listweareon*/
intmagic_debug_cookie;
structsk_buff*link3;/*LinkforIPprotocollevelbufferchains*/
structsock*sk;/*Socketweareownedby*/
unsignedlongwhen;/*usedtocomputertt's*/
structtimevalstamp;/*Timewearrived*/
structdevice*dev;/*Devicewearrivedon/areleavingby*/
union
{
structtcphdr*th;
structethhdr*eth;
structiphdr*iph;
structudphdr*uh;
unsignedchar*raw;
/*forpassingfilehandlesinaunixdomainsocket*/
void*filp;
}h;

union
{
/*Asyetincompletephysicallayerviews*/
unsignedchar*raw;
structethhdr*ethernet;
}mac;

structiphdr*ip_hdr;/*ForIPPROTO_RAW*/
unsignedlonglen;/*Lengthofactualdata*/
unsignedlongcsum;/*Checksum*/
__u32saddr;/*IPsourceaddress*/
__u32daddr;/*IPtargetaddress*/
__u32raddr;/*IPnexthopaddress*/
__u32seq;/*TCPsequencenumber*/
__u32end_seq;/*seq[+fin][+syn]+datalen*/
__u32ack_seq;/*TCPacksequencenumber*/
unsignedcharproto_priv[16];
volatilecharacked,/*Areweacked?*/
used,/*Areweinuse?*/
free,/*Howtofreethisbuffer*/
arp;/*HasIP/ARPresolutionfinished*/
unsignedchartries,/*Timestried*/
lock,/*Arewelocked?*/
localroute,/*Localroutingassertedforthisframe*/
pkt_type,/*Packetclass*/
pkt_bridged,/*Trackerforbridging*/
ip_summed;/*DriverfedusanIPchecksum*/
#definePACKET_HOST0/*Tous*/
#definePACKET_BROADCAST1/*Toall*/
#definePACKET_MULTICAST2/*Togroup*/
#definePACKET_OTHERHOST3/*Tosomeoneelse*/
unsignedshortusers;/*Usercount-seedatagram.c,tcp.c*/
unsignedshortprotocol;/*Packetprotocolfromdriver.*/
unsignedinttruesize;/*Buffersize*/
atomic_tcount;/*referencecount*/
structsk_buff*data_skb;/*Linktotheactualdataskb*/
unsignedchar*head;/*Headofbuffer*/
unsignedchar*data;/*Dataheadpointer*/
unsignedchar*tail;/*Tailpointer*/
unsignedchar*end;/*Endpointer*/
void(*destructor)(structsk_buff*);/*Destructfunction*/
__u16redirport;/*Redirectport*/
};

sock
包含BSD套接口的协议相关信息。例如对于一个INET(InternetAddressDomain)套接口此数据结构包含TCP/IP和UDP/IP信息。

structsock
{
/*Thismustbefirst.*/
structsock*sklist_next;
structsock*sklist_prev;

structoptions*opt;
atomic_twmem_alloc;
atomic_trmem_alloc;
unsignedlongallocation;/*Allocationmode*/
__u32write_seq;
__u32sent_seq;
__u32acked_seq;
__u32copied_seq;
__u32rcv_ack_seq;
unsignedshortrcv_ack_cnt;/*countofsameack*/
__u32window_seq;
__u32fin_seq;
__u32urg_seq;
__u32urg_data;
__u32syn_seq;
intusers;/*usercount*/
/*
*Notallarevolatile,butsomeare,sowe
*mightaswellsaytheyallare.
*/
volatilechardead,
urginline,
intr,
blog,
done,
reuse,
keepopen,
linger,
delay_acks,
destroy,
ack_timed,
no_check,
zapped,
broadcast,
nonagle,
bsdism;
unsignedlonglingertime;
intproc;

structsock*next;
structsock**pprev;
structsock*bind_next;
structsock**bind_pprev;
structsock*pair;
inthashent;
structsock*prev;
structsk_buff*volatilesend_head;
structsk_buff*volatilesend_next;
structsk_buff*volatilesend_tail;
structsk_buff_headback_log;
structsk_buff*partial;
structtimer_listpartial_timer;
longretransmits;
structsk_buff_headwrite_queue,
receive_queue;
structproto*prot;
structwait_queue**sleep;
__u32daddr;
__u32saddr;/*Sendingsource*/
__u32rcv_saddr;/*Boundaddress*/
unsignedshortmax_unacked;
unsignedshortwindow;
__u32lastwin_seq;/*sequencenumberwhenwelast
updatedthewindowweoffer*/
__u32high_seq;/*sequencenumberwhenwedid
currentfastretransmit*/
volatileunsignedlongato;/*acktimeout*/
volatileunsignedlonglrcvtime;/*jiffiesatlastdatarcv*/
volatileunsignedlongidletime;/*jiffiesatlastrcv*/
unsignedintbytes_rcv;
/*
*mssismin(mtu,max_window)
*/
unsignedshortmtu;/*mssnegotiatedinthesyn's*/
volatileunsignedshortmss;/*currenteff.mss-canchange*/
volatileunsignedshortuser_mss;/*mssrequestedbyuserinioctl*/
volatileunsignedshortmax_window;
unsignedlongwindow_clamp;
unsignedintssthresh;
unsignedshortnum;
volatileunsignedshortcong_window;
volatileunsignedshortcong_count;
volatileunsignedshortpackets_out;
volatileunsignedshortshutdown;
volatileunsignedlongrtt;
volatileunsignedlongmdev;
volatileunsignedlongrto;

volatileunsignedshortbackoff;
interr,err_soft;/*Softholdserrorsthatdon't
causefailurebutarethecause
ofapersistentfailurenot
just'timedout'*/
unsignedcharprotocol;
volatileunsignedcharstate;
unsignedcharack_backlog;
unsignedcharmax_ack_backlog;
unsignedcharpriority;
unsignedchardebug;
intrcvbuf;
intsndbuf;
unsignedshorttype;
unsignedcharlocalroute;/*Routelocallyonly*/
/*
*Thisiswherealltheprivate(optional)areasthatdon't
*overlapwilleventuallylive.
*/
union
{
structunix_optaf_unix;
#ifdefined(CONFIG_ATALK)||defined(CONFIG_ATALK_MODULE)
structatalk_sockaf_at;
#endif
#ifdefined(CONFIG_IPX)||defined(CONFIG_IPX_MODULE)
structipx_optaf_ipx;
#endif
#ifdefCONFIG_INET
structinet_packet_optaf_packet;
#ifdefCONFIG_NUTCP
structtcp_optaf_tcp;
#endif
#endif
}protinfo;
/*
*IP'privatearea'
*/
intip_ttl;/*TTLsetting*/
intip_tos;/*TOS*/
structtcphdrdummy_th;
structtimer_listkeepalive_timer;/*TCPkeepalivehack*/
structtimer_listretransmit_timer;/*TCPretransmittimer*/
structtimer_listdelack_timer;/*TCPdelayedacktimer*/
intip_xmit_timeout;/*Whythetimeoutisrunning*/
structrtable*ip_route_cache;/*Cachedoutputroute*/
unsignedcharip_hdrincl;/*Includeheaders?*/
#ifdefCONFIG_IP_MULTICAST
intip_mc_ttl;/*MulticastingTTL*/
intip_mc_loop;/*Loopback*/
charip_mc_name[MAX_ADDR_LEN];/*Multicastdevicename*/
structip_mc_socklist*ip_mc_list;/*Grouparray*/
#endif

/*
*Thispartisusedforthetimeoutfunctions(timer.c).
*/
inttimeout;/*Whatarewewaitingfor?*/
structtimer_listtimer;/*ThisistheTIME_WAIT/receive
*timerwhenwearedoingIP
*/
structtimevalstamp;
/*
*Identd
*/
structsocket*socket;
/*
*Callbacks
*/
void(*state_change)(structsock*sk);
void(*data_ready)(structsock*sk,intbytes);
void(*write_space)(structsock*sk);
void(*error_report)(structsock*sk);

};

socket
包含BSD套接口的信息。它不独立存在,一般位于一个VFSinode结构中。

structsocket{
shorttype;/*SOCK_STREAM,...*/
socket_statestate;
longflags;
structproto_ops*ops;/*protocolsdomosteverything*/
void*data;/*protocoldata*/
structsocket*conn;/*serversocketconnectedto*/
structsocket*iconn;/*incompleteclientconn.s*/
structsocket*next;
structwait_queue**wait;/*ptrtoplacetowaiton*/
structinode*inode;
structfasync_struct*fasync_list;/*Asynchronouswakeuplist*/
structfile*file;/*Filebackpointerforgc*/
};

task_struct
用来描叙系统中的进程或任务。

structtask_struct{
/*thesearehardcoded-don'ttouch*/
volatilelongstate;/*-1unrunnable,0runnable,>0stopped*/
longcounter;
longpriority;
unsignedlongsignal;
unsignedlongblocked;/*bitmapofmaskedsignals*/
unsignedlongflags;/*perprocessflags,definedbelow*/
interrno;
longdebugreg[8];/*Hardwaredebuggingregisters*/
structexec_domain*exec_domain;
/*variousfields*/
structlinux_binfmt*binfmt;
structtask_struct*next_task,*prev_task;
structtask_struct*next_run,*prev_run;
unsignedlongsaved_kernel_stack;
unsignedlongkernel_stack_page;
intexit_code,exit_signal;
/*???*/
unsignedlongpersonality;
intdumpable:1;
intdid_exec:1;
intpid;
intpgrp;
inttty_old_pgrp;
intsession;
/*booleanvalueforsessiongroupleader*/
intleader;
intgroups[NGROUPS];
/*
*pointersto(original)parentprocess,youngestchild,youngersibling,
*oldersibling,respectively.(p->fathercanbereplacedwith
*p->p_pptr->pid)
*/
structtask_struct*p_opptr,*p_pptr,*p_cptr,
*p_ysptr,*p_osptr;
structwait_queue*wait_chldexit;
unsignedshortuid,euid,suid,fsuid;
unsignedshortgid,egid,sgid,fsgid;
unsignedlongtimeout,policy,rt_priority;
unsignedlongit_real_value,it_prof_value,it_virt_value;
unsignedlongit_real_incr,it_prof_incr,it_virt_incr;
structtimer_listreal_timer;
longutime,stime,cutime,cstime,start_time;
/*mmfaultandswapinfo:thiscanarguablybeseenaseither
mm-specificorthread-specific*/
unsignedlongmin_flt,maj_flt,nswap,cmin_flt,cmaj_flt,cnswap;
intswappable:1;
unsignedlongswap_address;
unsignedlongold_maj_flt;/*oldvalueofmaj_flt*/
unsignedlongdec_flt;/*pagefaultcountofthelasttime*/
unsignedlongswap_cnt;/*numberofpagestoswaponnextpass*/
/*limits*/
structrlimitrlim[RLIM_NLIMITS];
unsignedshortused_math;
charcomm[16];
/*filesysteminfo*/
intlink_count;
structtty_struct*tty;/*NULLifnotty*/
/*ipcstuff*/
structsem_undo*semundo;
structsem_queue*semsleeping;
/*ldtforthistask-usedbyWine.IfNULL,default_ldtisused*/
structdesc_struct*ldt;
/*tssforthistask*/
structthread_structtss;
/*filesysteminformation*/
structfs_struct*fs;
/*openfileinformation*/
structfiles_struct*files;
/*memorymanagementinfo*/
structmm_struct*mm;
/*signalhandlers*/
structsignal_struct*sig;
#ifdef__SMP__
intprocessor;
intlast_processor;
intlock_depth;/*Lockdepth.
Wecancontextswitchinandout
ofholdingasyscallkernellock...*/
#endif
};

timer_list
用来为进程实现实时时钟。

structtimer_list{
structtimer_list*next;
structtimer_list*prev;
unsignedlongexpires;
unsignedlongdata;
void(*function)(unsignedlong);
};

tq_struct
每个任务队列结构(tq_struct)包含着已经排队的任务信息。它被设备驱动用来描叙那些无需立刻执行的任务。

structtq_struct{
structtq_struct*next;/*linkedlistofactivebh's*/
intsync;/*mustbeinitializedtozero*/
void(*routine)(void*);/*functiontocall*/
void*data;/*argumenttofunction*/
};

vm_area_struct
表示某进程的一个虚拟内存区域。

structvm_area_struct{
structmm_struct*vm_mm;/*VMareaparameters*/
unsignedlongvm_start;
unsignedlongvm_end;
pgprot_tvm_page_prot;
unsignedshortvm_flags;
/*AVLtreeofVMareaspertask,sortedbyaddress*/
shortvm_avl_height;
structvm_area_struct*vm_avl_left;
structvm_area_struct*vm_avl_right;
/*linkedlistofVMareaspertask,sortedbyaddress*/
structvm_area_struct*vm_next;
/*forareaswithinode,thecircularlistinode->i_mmap*/
/*forshmareas,thecircularlistofattaches*/
/*otherwiseunused*/
structvm_area_struct*vm_next_share;
structvm_area_struct*vm_prev_share;
/*more*/
structvm_operations_struct*vm_ops;
unsignedlongvm_offset;
structinode*vm_inode;
unsignedlongvm_pte;/*sharedmem*/
};

版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友