Ubuntu 16.04LTS introduced a rather arcane naming convention for ethernet ports. To be able to continue using the traditional eth0/eth1 names I added the following file. Note that you will need to substitute the appropriate NIC addresses in the 'ATTR{address}==' fields:
# This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device (eno1) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="9c:5c:8e:50:01:nn", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0" # PCI device (enp18s0) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="9c:5c:8e:50:01:nn", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth1"
Since we want realtime response from our dfcSDR programs, we can reserve one or more CPUs exclusively for the program.
Edit /etc/default/grub by adding isolcpus=
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash isolcpus=6,7"
After modifying the grub file you must update grub's database and reboot:
$ sudo update-grub
$ sudo reboot
You can enable a dfcSDR program to use the reserved CPU(s) with this code:
#include <sched.h>
...
/*
* Schedule this process to run on a specific CPU.
*/
size_t size = CPU_ALLOC_SIZE(2); // unsigned long int granularity,
cpu_set_t* setPtr = CPU_ALLOC(size); // a 32 bit machine will = 32 CPUs minimim
CPU_ZERO_S(size, setPtr); // a 64 bit machine will = 64 CPUs minimum
/* Get list of available CPUs. */
if (sched_getaffinity(0, size, setPtr) < 0) {
perror("can't getaffinity");
exit(-1);
}
/* Assume the highest numbered CPU is reserved. */
int xx = CPU_COUNT_S(size, setPtr); // actual number of available CPUs
int useCpu = 0;
for (int x = 0; x < xx; ++x) {
if (CPU_ISSET(x, setPtr) && (x > useCpu))
useCpu = x;
}
/* Set affinity. */
CPU_ZERO_S(size, setPtr);
CPU_SET(useCpu, setPtr);
if (sched_setaffinity(0, size, setPtr) < 0) {
perror("can't setaffinity");
exit(-1);
}
/* Free resources. */
CPU_FREE(setPtr);
...
/* Verify which CPU we are using. */
printf(stderr, "cudaLoop() running on CPU: %d", sched_getcpu());