如何解决如何在dpdk 18.11中设置线程名称
在dpdk 17.05中,结构lcore_config是公共的,而pthread_t可以通过lcore_config [lcore_id] .thread_id获得。 在18.11结构中,lcore_config是私有的,如何获得pthread_t作为lcore_id?
问题-我无法使用pthread_setname_np(
rte_gettid()
返回int
,但我需要pthread_t
解决方法
在DPDK rte_lcore.h
中,API rte_thread_setname
负责设置备用名称,而不是DPDK分配的名称。在Linux中,DPDK在内部调用pthread_setname_np
。
DPDK版本:dpdk-stable-18.11.10 如果glbc> 2.12,请按照DPDK代码库的设置名[edit-1] glibc版本:Ubuntu GLIBC 2.30-0ubuntu2.2
在C文件中修改的代码:
printf("hello from core %u\n",lcore_id);
snprintf(name,100,"hello-%d",lcore_id);
if (rte_thread_setname( pthread_self(),name) == 0)
printf(" thread name %s\n",name);
CFLAGS已添加到Makefile:
CFLAGS += -DALLOW_EXPERIMENTAL_API
或使用EXTRA_CFLAGS=-DALLOW_EXPERIMENTAL_API make
36986 root 20 0 227916 6996 6024 R 93.8 0.0 0:40.60 helloworld
37004 root 20 0 227916 6996 6024 R 93.8 0.0 0:40.61 lcore-slave-1
37005 root 20 0 227916 6996 6024 R 93.8 0.0 0:40.61 lcore-slave-2
37006 root 20 0 227916 6996 6024 R 93.8 0.0 0:40.61 lcore-slave-3
调用后
15326 root 20 0 153312 7728 5976 T 0.0 0.2 0:03.32 hello-0
15327 root 20 0 153312 7728 5976 T 0.0 0.2 0:00.00 eal-intr-thread
15328 root 20 0 153312 7728 5976 T 0.0 0.2 0:00.00 rte_mp_handle
15329 root 20 0 153312 7728 5976 T 0.0 0.2 0:03.32 hello-1
15330 root 20 0 153312 7728 5976 T 0.0 0.2 0:03.32 hello-2
15331 root 20 0 153312 7728 5976 T 0.0 0.2 0:03.32 hello-3
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。