声明:此文档只做学习交流使用,请勿用作其他商业用途
author:朝阳_tony 转载请注明出处:http://blog.csdn.net/linzhaolover
此文中源码可以去http://dpdk.org/dev 网页中下载;更多官方文档请访问http://dpdk.org
fd = open(DEV_HPET, O_RDONLY);去打开/dev/hpet设备文件描述符;
eal_hpet = mmap(NULL, 1024, PROT_READ, MAP_SHARED, fd, 0);映射一块1024大小的内存空间;
ret = pthread_create(&msb_inc_thread_id, NULL, hpet_msb_inc, NULL);创建hpet_msb_inc线程;
static __attribute__((noreturn)) void * hpet_msb_inc(__attribute__((unused)) void *arg) { uint32_t t; while (1) { t = (eal_hpet->counter_l >> 30); if (t != (eal_hpet_msb & 3)) eal_hpet_msb ++; sleep(10); } }
void rte_delay_us(unsigned us) { uint64_t start; uint64_t ticks; ticks = (uint64_t)us * 1000ULL * 1000ULL * 1000ULL; ticks /= eal_hpet_resolution_fs; start = rte_get_hpet_cycles(); while ((rte_get_hpet_cycles() - start) < ticks) rte_pause(); }