Changeset 773d5e2
- Timestamp:
- 03/24/15 12:54:51 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- e0be8382
- Parents:
- 6b98325
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_dpdk.c
r6b98325 r773d5e2 163 163 #include <rte_cycles.h> 164 164 #include <pthread.h> 165 #ifdef __FreeBSD__ 166 #include <pthread_np.h> 167 #endif 168 165 169 166 170 /* The default size of memory buffers to use - This is the max size of standard -
lib/trace_parallel.c
r6b98325 r773d5e2 119 119 static void print_memory_stats() { 120 120 #if 0 121 uint64_t total; 122 #ifdef __linux__ 121 123 char t_name[50]; 122 uint64_t total;123 124 pthread_getname_np(pthread_self(), t_name, sizeof(t_name)); 124 125 125 126 fprintf(stderr, "Thread ID#%d - %s\n", (int) pthread_self(), t_name); 127 #else 128 fprintf(stderr, "Thread ID#%d\n", (int) pthread_self()); 129 #endif 126 130 127 131 total = mem_hits.read.cache_hit + mem_hits.read.ring_hit + mem_hits.read.miss; … … 165 169 /* 166 170 * This can be used once the hasher thread has been started and internally after 167 * ver fiy_configuration.171 * verify_configuration. 168 172 */ 169 173 DLLEXPORT bool trace_has_dedicated_hasher(libtrace_t * libtrace) … … 1347 1351 */ 1348 1352 SIMPLE_FUNCTION static int get_nb_cores() { 1349 // TODO add BSD support 1350 return sysconf(_SC_NPROCESSORS_ONLN); 1353 int numCPU; 1354 #ifdef _SC_NPROCESSORS_ONLN 1355 /* Most systems do this now */ 1356 numCPU = sysconf(_SC_NPROCESSORS_ONLN); 1357 1358 #else 1359 int mib[] = {CTL_HW, HW_AVAILCPU}; 1360 size_t len = sizeof(numCPU); 1361 1362 /* get the number of CPUs from the system */ 1363 sysctl(mib, 2, &numCPU, &len, NULL, 0); 1364 #endif 1365 return numCPU <= 0 ? 1 : numCPU; 1351 1366 } 1352 1367 … … 1412 1427 int perpkt_num, 1413 1428 const char *name) { 1429 #ifdef __linux__ 1414 1430 pthread_attr_t attrib; 1415 1431 cpu_set_t cpus; 1432 #endif 1416 1433 int ret, i; 1417 1434 assert(t->type == THREAD_EMPTY); … … 1422 1439 t->state = THREAD_RUNNING; 1423 1440 1441 #ifdef __linux__ 1424 1442 CPU_ZERO(&cpus); 1425 1443 for (i = 0; i < get_nb_cores(); i++) … … 1427 1445 pthread_attr_init(&attrib); 1428 1446 pthread_attr_setaffinity_np(&attrib, sizeof(cpus), &cpus); 1429 1430 1447 ret = pthread_create(&t->tid, &attrib, start_routine, (void *) trace); 1431 1448 pthread_attr_destroy(&attrib); 1449 #else 1450 ret = pthread_create(&t->tid, NULL, start_routine, (void *) trace); 1451 #endif 1432 1452 if (ret != 0) { 1433 1453 libtrace_zero_thread(t); … … 1443 1463 LIBTRACE_RINGBUFFER_BLOCKING); 1444 1464 } 1465 #ifdef __linux__ 1445 1466 if(name) 1446 1467 pthread_setname_np(t->tid, name); 1468 #endif 1447 1469 t->perpkt_num = perpkt_num; 1448 1470 return 0;
Note: See TracChangeset
for help on using the changeset viewer.