首页 > 编程语言 > 详细

zebra/quagga线程分析

时间:2015-10-18 23:03:48      阅读:333      评论:0      收藏:0      [点我收藏+]
/* 线程按照不同的功能进行分类。有6条双链,分别表示不同类型的线程。将要运行的时候,
* 就从不同的链表中取出,添加到ready链表中,运行完成之后,将线程结构体清空放到
* unuse链表中。一般利用现有unuse链表的资源,根据功能添加在不同的链表中。
* 只有当线程结构体都使用了,即ununse链表空的时候,才重新申请新的空间 */
struct thread_master { struct thread_list read; struct thread_list write; struct thread_list timer; struct thread_list event; struct thread_list ready; struct thread_list unuse; fd_set readfd; fd_set writefd; fd_set exceptfd; unsigned long alloc; }; /* thread_list结构体用于记录每种链表的信息。head指向双链表头,tail指向双链表尾
* count记录当前链表中有多少个节点 */
struct thread_list { struct thread *head; struct thread *tail; int count; }; /* 单个线程的数据,按照功能不同包含在不同的thread_list结构中。
* 线程调用完成之后,将内部的信息清空,添加到unuse链表中 */
struct thread { thread_type type; thread_type add_type; struct thread *next; struct thread *prev; struct thread_master *master; int (*func) (struct thread *); /* 线程中保存的处理函数 */ void *arg; /* 线程中保存的参数 */ union {   int val;   int fd;   struct timeval sands; } u; RUSAGE_T ru; struct cpu_thread_history *hist; char* funcname; };

 

zebra/quagga线程分析

原文:http://www.cnblogs.com/helloworldtoyou/p/4890578.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!