#include <cstdlib>
#include <fstream>
#include <sstream>
+#include <thread>
extern "C" {
#include <signal.h>
}
// Exploit SMP parallelism, if available.
- long smp = sysconf(_SC_NPROCESSORS_ONLN);
+ long smp = thread::hardware_concurrency();
if (smp <= 0) smp = 1;
// PR16276: but only if we're not running severely nproc-rlimited
struct rlimit rlim;
#include "stap-probe.h"
#include <cstdlib>
+#include <thread>
extern "C" {
#include <glob.h>
}
-static void*
-sdt_benchmark_thread(void* p)
+static void
+sdt_benchmark_thread(unsigned long i)
{
- unsigned long i = *(unsigned long*)p;
PROBE(stap, benchmark__thread__start);
while (i--)
PROBE1(stap, benchmark, i);
PROBE(stap, benchmark__thread__end);
- return NULL;
}
gettimeofday (&tv_before, NULL);
PROBE(stap, benchmark__start);
-
- pthread_t pthreads[threads];
- for (unsigned long i = 0; i < threads; ++i)
- pthread_create(&pthreads[i], NULL, sdt_benchmark_thread, &loops);
- for (unsigned long i = 0; i < threads; ++i)
- pthread_join(pthreads[i], NULL);
-
+ {
+ vector<thread> handles;
+ for (unsigned long i = 0; i < threads; ++i)
+ handles.push_back(thread(sdt_benchmark_thread, loops));
+ for (unsigned long i = 0; i < threads; ++i)
+ handles[i].join();
+ }
PROBE(stap, benchmark__end);
times (& tms_after);
#include <cerrno>
#include <cstdlib>
+#include <thread>
extern "C" {
#include <getopt.h>
case LONG_OPT_BENCHMARK_SDT:
// XXX This option is secret, not supported, subject to change at our whim
- benchmark_sdt_threads = sysconf(_SC_NPROCESSORS_ONLN);
+ benchmark_sdt_threads = thread::hardware_concurrency();
break;
case LONG_OPT_BENCHMARK_SDT_LOOPS:
#include <climits>
#include <iostream>
#include <map>
+#include <thread>
extern "C" {
#include <unistd.h>
// Initial values.
use_db_password = false;
port = 0;
- max_threads = sysconf( _SC_NPROCESSORS_ONLN ); // Default to number of processors
+ max_threads = thread::hardware_concurrency(); // Default to number of processors
max_uncompressed_req_size = 50000; // 50 KB: default max uncompressed request size
max_compressed_req_size = 5000; // 5 KB: default max compressed request size
keep_temp = false;