projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reduced timeouts by 10x
[invirt/third/libt4.git]
/
lock_tester.cc
diff --git
a/lock_tester.cc
b/lock_tester.cc
index
c192128
..
84ac5cc
100644
(file)
--- a/
lock_tester.cc
+++ b/
lock_tester.cc
@@
-11,7
+11,7
@@
char log_thread_prefix = 'c';
// must be >= 2
const int nt = 6; //XXX: lab1's rpc handlers are blocking. Since rpcs uses a thread pool of 10 threads, we cannot test more than 10 blocking rpc.
// must be >= 2
const int nt = 6; //XXX: lab1's rpc handlers are blocking. Since rpcs uses a thread pool of 10 threads, we cannot test more than 10 blocking rpc.
-std::string dst;
+string dst;
lock_client **lc = new lock_client * [nt];
lock_protocol::lockid_t a = "1";
lock_protocol::lockid_t b = "2";
lock_client **lc = new lock_client * [nt];
lock_protocol::lockid_t a = "1";
lock_protocol::lockid_t b = "2";
@@
-21,7
+21,7
@@
lock_protocol::lockid_t c = "3";
// doesn't grant the same lock to both clients.
// it assumes that lock names are distinct in the first byte.
int ct[256];
// doesn't grant the same lock to both clients.
// it assumes that lock names are distinct in the first byte.
int ct[256];
-std::mutex count_mutex;
+mutex count_mutex;
void check_grant(lock_protocol::lockid_t lid) {
lock ml(count_mutex);
void check_grant(lock_protocol::lockid_t lid) {
lock ml(count_mutex);
@@
-71,7
+71,7
@@
void test2(int i) {
lc[i]->acquire(a);
LOG_NONMEMBER("test2: client " << i << " acquire done");
check_grant(a);
lc[i]->acquire(a);
LOG_NONMEMBER("test2: client " << i << " acquire done");
check_grant(a);
- sleep(1);
+ usleep(100000);
LOG_NONMEMBER("test2: client " << i << " release");
check_release(a);
lc[i]->release(a);
LOG_NONMEMBER("test2: client " << i << " release");
check_release(a);
lc[i]->release(a);
@@
-116,7
+116,7
@@
void test5(int i) {
int
main(int argc, char *argv[])
{
int
main(int argc, char *argv[])
{
- std::thread th[nt];
+ thread th[nt];
int test = 0;
setvbuf(stdout, NULL, _IONBF, 0);
int test = 0;
setvbuf(stdout, NULL, _IONBF, 0);
@@
-148,7
+148,7
@@
main(int argc, char *argv[])
if (!test || test == 2) {
// test2
for (int i = 0; i < nt; i++)
if (!test || test == 2) {
// test2
for (int i = 0; i < nt; i++)
- th[i] = std::thread(test2, i);
+ th[i] = thread(test2, i);
for (int i = 0; i < nt; i++)
th[i].join();
}
for (int i = 0; i < nt; i++)
th[i].join();
}
@@
-157,7
+157,7
@@
main(int argc, char *argv[])
LOG_NONMEMBER("test 3");
for (int i = 0; i < nt; i++)
LOG_NONMEMBER("test 3");
for (int i = 0; i < nt; i++)
- th[i] = std::thread(test3, i);
+ th[i] = thread(test3, i);
for (int i = 0; i < nt; i++)
th[i].join();
}
for (int i = 0; i < nt; i++)
th[i].join();
}
@@
-166,7
+166,7
@@
main(int argc, char *argv[])
LOG_NONMEMBER("test 4");
for (int i = 0; i < 2; i++)
LOG_NONMEMBER("test 4");
for (int i = 0; i < 2; i++)
- th[i] = std::thread(test4, i);
+ th[i] = thread(test4, i);
for (int i = 0; i < 2; i++)
th[i].join();
}
for (int i = 0; i < 2; i++)
th[i].join();
}
@@
-175,7
+175,7
@@
main(int argc, char *argv[])
LOG_NONMEMBER("test 5");
for (int i = 0; i < nt; i++)
LOG_NONMEMBER("test 5");
for (int i = 0; i < nt; i++)
- th[i] = std::thread(test5, i);
+ th[i] = thread(test5, i);
for (int i = 0; i < nt; i++)
th[i].join();
}
for (int i = 0; i < nt; i++)
th[i].join();
}