255. Sample Application Tests: Timer Example¶
This example shows how timer can be used in a RTE application. This program print some messages from different lcores regularly, demonstrating how to use timers.
If using vfio the kernel must be >= 3.6+ and VT-d must be enabled in bios.When using vfio, use the following commands to load the vfio driver and bind it to the device under test:
modprobe vfio modprobe vfio-pci usertools/dpdk-devbind.py --bind=vfio-pci device_bus_id
In the timer example there are two timers.
Timer 0 is periodical, running on the master lcore, reloaded automatically every second.
Timer 1 is single one, being loaded manually by every second/3 , once manually load will switch to next lcore.
Usage of application:
./timer [EAL options]
Where the EAL options are:
EAL option list: -c COREMASK: hexadecimal bitmask of cores we are running on -m MB : memory to allocate (default = size of hugemem) -n NUM : force number of memory channels (don't detect) -r NUM : force number of memory ranks (don't detect) --huge-file: base filename for hugetlbfs entries debug options: --no-huge : use malloc instead of hugetlbfs --no-pci : disable pci --no-hpet : disable hpet --no-shconf: no shared config (mmap'd files)
To find out the mapping of lcores (processor) to core id and socket (physical id), the command below can be used:
$ grep "processor\|physical id\|core id\|^$" /proc/cpuinfo
The number of logical core will be used as parameter to the timer example.
255.2. Test Case: timer callbacks running on targeted cores¶
To run the example in linuxapp environment:
./timer -c ffffff
Timer0, every second, on master lcore, reloaded automatically. The check output as below by every second on master lcore:
timer0_cb() on lcore 0
Timer1, every second/3, on next lcore, reloaded manually. The check output as below by every second/3 on master lcore:
timer1_cb() on lcore 1 timer1_cb() on lcore 2 timer1_cb() on lcore 3 timer1_cb() on lcore 4 ... ... ... timer1_cb() on lcore 23
timer1_cb care called properly
on the target cores.