projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanups
[invirt/third/libt4.git]
/
lock_tester.cc
diff --git
a/lock_tester.cc
b/lock_tester.cc
index
5c78c90
..
f4e68bd
100644
(file)
--- a/
lock_tester.cc
+++ b/
lock_tester.cc
@@
-81,10
+81,8
@@
test1(void)
}
void *
}
void *
-test2(void *x)
+test2(int i)
{
{
- int i = * (int *) x;
-
tprintf ("test2: client %d acquire a release a\n", i);
lc[i]->acquire(a);
tprintf ("test2: client %d acquire done\n", i);
tprintf ("test2: client %d acquire a release a\n", i);
lc[i]->acquire(a);
tprintf ("test2: client %d acquire done\n", i);
@@
-98,10
+96,8
@@
test2(void *x)
}
void *
}
void *
-test3(void *x)
+test3(int i)
{
{
- int i = * (int *) x;
-
tprintf ("test3: client %d acquire a release a concurrent\n", i);
for (int j = 0; j < 10; j++) {
lc[i]->acquire(a);
tprintf ("test3: client %d acquire a release a concurrent\n", i);
for (int j = 0; j < 10; j++) {
lc[i]->acquire(a);
@@
-114,10
+110,8
@@
test3(void *x)
}
void *
}
void *
-test4(void *x)
+test4(int i)
{
{
- int i = * (int *) x;
-
tprintf ("test4: thread %d acquire a release a concurrent; same clnt\n", i);
for (int j = 0; j < 10; j++) {
lc[0]->acquire(a);
tprintf ("test4: thread %d acquire a release a concurrent; same clnt\n", i);
for (int j = 0; j < 10; j++) {
lc[0]->acquire(a);
@@
-130,10
+124,8
@@
test4(void *x)
}
void *
}
void *
-test5(void *x)
+test5(int i)
{
{
- int i = * (int *) x;
-
tprintf ("test5: client %d acquire a release a concurrent; same and diff clnt\n", i);
for (int j = 0; j < 10; j++) {
if (i < 5) lc[0]->acquire(a);
tprintf ("test5: client %d acquire a release a concurrent; same and diff clnt\n", i);
for (int j = 0; j < 10; j++) {
if (i < 5) lc[0]->acquire(a);
@@
-155,7
+147,7
@@
main(int argc, char *argv[])
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
- srandom(getpid());
+ srandom((uint32_t)getpid());
if(argc < 2) {
fprintf(stderr, "Usage: %s [host:]port [test]\n", argv[0]);
if(argc < 2) {
fprintf(stderr, "Usage: %s [host:]port [test]\n", argv[0]);
@@
-181,53
+173,40
@@
main(int argc, char *argv[])
if(!test || test == 2){
// test2
if(!test || test == 2){
// test2
- for (int i = 0; i < nt; i++) {
- int *a = new int (i);
- th[i] = std::thread(test2, a);
- }
- for (int i = 0; i < nt; i++) {
+ for (int i = 0; i < nt; i++)
+ th[i] = std::thread(test2, i);
+ for (int i = 0; i < nt; i++)
th[i].join();
th[i].join();
- }
}
if(!test || test == 3){
tprintf("test 3\n");
// test3
}
if(!test || test == 3){
tprintf("test 3\n");
// test3
- for (int i = 0; i < nt; i++) {
- int *a = new int (i);
- th[i] = std::thread(test3, a);
- }
- for (int i = 0; i < nt; i++) {
+ for (int i = 0; i < nt; i++)
+ th[i] = std::thread(test3, i);
+ for (int i = 0; i < nt; i++)
th[i].join();
th[i].join();
- }
}
if(!test || test == 4){
tprintf("test 4\n");
// test 4
}
if(!test || test == 4){
tprintf("test 4\n");
// test 4
- for (int i = 0; i < 2; i++) {
- int *a = new int (i);
- th[i] = std::thread(test4, a);
- }
- for (int i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++)
+ th[i] = std::thread(test4, i);
+ for (int i = 0; i < 2; i++)
th[i].join();
th[i].join();
- }
}
if(!test || test == 5){
tprintf("test 5\n");
// test 5
}
if(!test || test == 5){
tprintf("test 5\n");
// test 5
-
- for (int i = 0; i < nt; i++) {
- int *a = new int (i);
- th[i] = std::thread(test5, a);
- }
- for (int i = 0; i < nt; i++) {
+ for (int i = 0; i < nt; i++)
+ th[i] = std::thread(test5, i);
+ for (int i = 0; i < nt; i++)
th[i].join();
th[i].join();
- }
}
tprintf ("%s: passed all tests successfully\n", argv[0]);
}
tprintf ("%s: passed all tests successfully\n", argv[0]);