线程启动流程
以worker线程为例,介绍线程启动流程:
线程注册:
VLIB_REGISTER_THREAD线程注册宏注册到全局 vlib_thread_main->next链表上。
typedef struct vlib_thread_registration_ {
/* constructor generated list of thread registrations */
struct vlib_thread_registration_ * next;
/* config parameters */
char * name;/*启动文件中启动几个"workers"线程 corelist-workers 3-11*/
char * short_name; /*线程重命名使用*/
vlib_thread_function_t * function;
uword mheap_size;
int fixed_count;
u32 count;
/*这个参数比较重要,如果线程不需要转发报文,可以置位1*/
int no_data_structure_clone;
u32 frame_queue_nelts;
/* All threads of this type run on pthreads */
int use_pthreads;/*设置变量标识绑定在父线程,就是可以理解为不绑核,共用父线程的资源*/
u32 first_index;
uword * coremask;
} vlib_thread_registration_t;
复制
workers 线程注册