Linux 核心--16.Linux数据结构( 七 )


 *overlap will eventually live.
 */
union
{
struct unix_opt af_unix;
#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
struct atalk_sock af_at;
#endif
#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
struct ipx_optaf_ipx;
#endif
#ifdef CONFIG_INET
struct inet_packet_optaf_packet;
#ifdef CONFIG_NUTCP
struct tcp_optaf_tcp;
#endif
#endif
} protinfo;
/*
 *IP "private area"
 */
int ip_ttl; /* TTL setting */
int ip_tos; /* TOS */
struct tcphdr dummy_th;
struct timer_list keepalive_timer;/* TCP keepalive hack */
struct timer_list retransmit_timer; /* TCP retransmit timer */
struct timer_list delack_timer; /* TCP delayed ack timer */
int ip_xmit_timeout;/* Why the timeout is running */
struct rtable *ip_route_cache;/* Cached output route */
unsigned char ip_hdrincl; /* Include headers ? */
#ifdef CONFIG_IP_MULTICAST
int ip_mc_ttl;/* Multicasting TTL */
int ip_mc_loop; /* Loopback */
charip_mc_name[MAX_ADDR_LEN]; /* Multicast device name */
struct ip_mc_socklist *ip_mc_list;/* Group array */
#endif

/*
 *This part is used for the timeout functions (timer.c).
 */
inttimeout; /* What are we waiting for? */
struct timer_listtimer; /* This is the TIME_WAIT/receive
 * timer when we are doing IP
 */
struct timeval stamp;
 /*
*Identd
*/
struct socket*socket;
/*
 *Callbacks
 */
void (*state_change)(struct sock *sk);
void (*data_ready)(struct sock *sk,int bytes);
void (*write_space)(struct sock *sk);
void (*error_report)(struct sock *sk);

};

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

struct socket {
shorttype; /* SOCK_STREAM, ... */
socket_state state;
long flags;
struct proto_ops *ops; /* protocols do most everything */
void *data;/* protocol data*/
struct socket*conn;/* server socket connected to */
struct socket*iconn; /* incomplete client conn.s */
struct socket*next;
struct wait_queue**wait; /* ptr to place to wait on*/
struct inode *inode;
struct fasync_struct *fasync_list; /* Asynchronous wake up list*/
struct file*file;/* File back pointer for gc */
};

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

struct task_struct {
/* these are hardcoded - don"t touch */
volatile longstate;/* -1 unrunnable, 0 runnable, >0 stopped */
long counter;
long priority;
unsigned long signal;
unsigned long blocked; /* bitmap of masked signals */
unsigned long flags; /* per process flags, defined below */
int errno;
long debugreg[8];/* Hardware debugging registers */
struct exec_domain *exec_domain;
/* various fields */
struct linux_binfmt*binfmt;
struct task_struct *next_task, *prev_task;
struct task_struct *next_run,*prev_run;
unsigned longsaved_kernel_stack;
unsigned longkernel_stack_page;
intexit_code, exit_signal;
/* ??? */
unsigned longpersonality;
intdumpable:1;
intdid_exec:1;
intpid;
intpgrp;
inttty_old_pgrp;
intsession;
/* boolean value for session group leader */
intleader;
intgroups[NGROUPS];
/*
 * pointers to (original) parent process, youngest child, younger sibling,
 * older sibling, respectively.(p->father can be replaced with
 * p->p_pptr->pid)
 */
struct task_struct *p_opptr, *p_pptr, *p_cptr,

推荐阅读