Use libisc thread functions

(cherry picked from commit 051197362b)
This commit is contained in:
Mukund Sivaraman 2016-03-04 13:58:35 +05:30
parent d820e8ff8a
commit cb93542612
2 changed files with 12 additions and 22 deletions

View file

@ -25,6 +25,7 @@
#include <unistd.h>
#include <isc/os.h>
#include <isc/thread.h>
#include <dns/name.h>
#include <dns/fixedname.h>
@ -177,7 +178,7 @@ ATF_TC_BODY(benchmark, tc) {
isc_time_t ts1, ts2;
double t;
unsigned int nthreads;
pthread_t threads[32];
isc_thread_t threads[32];
UNUSED(tc);
@ -192,19 +193,13 @@ ATF_TC_BODY(benchmark, tc) {
nthreads = ISC_MIN(isc_os_ncpus(), 32);
nthreads = ISC_MAX(nthreads, 1);
for (i = 0; i < nthreads; i++) {
int s;
s = pthread_create(&threads[i], NULL, fromwire_thread, NULL);
ATF_REQUIRE(s == 0);
result = isc_thread_create(fromwire_thread, NULL, &threads[i]);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
}
for (i = 0; i < nthreads; i++) {
int s;
s = pthread_join(threads[i], NULL);
ATF_REQUIRE(s == 0);
result = isc_thread_join(threads[i], NULL);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
}
result = isc_time_now(&ts2);

View file

@ -47,6 +47,7 @@
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <isc/print.h>
@ -1364,7 +1365,7 @@ ATF_TC_BODY(benchmark, tc) {
isc_time_t ts1, ts2;
double t;
unsigned int nthreads;
pthread_t threads[32];
isc_thread_t threads[32];
UNUSED(tc);
@ -1407,19 +1408,13 @@ ATF_TC_BODY(benchmark, tc) {
nthreads = ISC_MIN(isc_os_ncpus(), 32);
nthreads = ISC_MAX(nthreads, 1);
for (i = 0; i < nthreads; i++) {
int s;
s = pthread_create(&threads[i], NULL, find_thread, mytree);
ATF_REQUIRE(s == 0);
result = isc_thread_create(find_thread, mytree, &threads[i]);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
}
for (i = 0; i < nthreads; i++) {
int s;
s = pthread_join(threads[i], NULL);
ATF_REQUIRE(s == 0);
result = isc_thread_join(threads[i], NULL);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
}
result = isc_time_now(&ts2);