Commit 3dac1ed8 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

solaris port. addresses #1789

git-svn-id: file:///svn/toku/tokudb@12606 c7de825b-a66e-492c-adef-691d508d4ae1
parent dc7f7419
......@@ -3,6 +3,7 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <thread.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/resource.h>
......@@ -37,6 +38,17 @@ toku_os_gettid(void) {
#endif
#if __sun__
int
toku_os_gettid(void) {
thread_t tid;
tid = thr_self();
return tid;
}
#endif
int
toku_os_get_number_processors(void) {
return sysconf(_SC_NPROCESSORS_CONF);
......
#include <stdio.h>
#include <assert.h>
#include <test.h>
#include <toku_pthread.h>
#include <toku_os.h>
#include <stdio.h>
#include <unistd.h>
void *f(void *arg) {
int r;
toku_pthread_rwlock_t *mylock = arg;
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_wrlock(mylock); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_wrunlock(mylock); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
return arg;
}
int test_main(int argc, char *argv[]) {
int r;
toku_pthread_rwlock_t rwlock;
const int nthreads = 2;
toku_pthread_t tid[nthreads];
void *retptr;
int i;
r = toku_pthread_rwlock_init(&rwlock, NULL); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_rdlock(&rwlock); assert(r == 0);
for (i=0; i<nthreads; i++) {
r = toku_pthread_create(&tid[i], NULL, f, &rwlock); assert(r == 0);
}
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
sleep(10);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_rdlock(&rwlock); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_rdunlock(&rwlock); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_rdunlock(&rwlock); assert(r == 0);
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
for (i=0; i<nthreads; i++) {
r = toku_pthread_join(tid[i], &retptr); assert(r == 0);
}
printf("%s:%d:%d\n", __FUNCTION__, __LINE__, toku_os_gettid()); fflush(stdout);
r = toku_pthread_rwlock_destroy(&rwlock); assert(r == 0);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment