在DPDK中,一个EAL process包含有若干个lcore,其中包含有一个master lcore以及若干slave lcore。
在Linux系统下,EAL层初始化时,主线程会读取系统目录/sys/devices/system/cpu下里面每一个cpuX目录,若能够检测到/sys/devices/system/cpu/cpuX/topology/core_id这一个文件,则表示允许此lcore运行。并且对于每一个lcore,分配一个lcore_config。
lcore_config的结构体如下 :
struct lcore_config {
unsigned detected; /**< true if lcore was detected */
//此lcore对应的pthread
pthread_t thread_id; /**< pthread identifier */
//pipe用于master lcore通知slave lcore执行函数f
int pipe_master2slave[2]; /**< communication pipe with master */
int pipe_slave2master[2]; /**< communication pipe with master */
//f, arg, ret表示slave lcore要执行的函数, 对应的参数,以及返回值
lcore_function_t * volatile f; /**< function to call */
void * volatile arg; /**< argument of function */
volatile int ret; /**< return value of function */
//state

本文介绍了DPDK中EAL过程的结构,包括master和slave lcore的角色。EAL初始化时,主线程会根据CPU拓扑创建lcore配置。每个Lcore都运行在pthread上,执行eal_thread_loop(),该循环用于初始化lcore信息并响应master lcore的命令。master lcore通过管道指挥slave lcore执行任务,并通过状态检查进行同步。部分lcore还可作为service lcore执行循环服务任务。
最低0.47元/天 解锁文章
4394

被折叠的 条评论
为什么被折叠?



