cleaned comments, output
This commit is contained in:
parent
9169bfc075
commit
58c99d52ba
1 changed files with 20 additions and 40 deletions
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
void * pageWorkerThread(void * j) {
|
void * pageWorkerThread(void * j) {
|
||||||
int xid = *(int*)j;
|
int xid = *(int*)j;
|
||||||
//startTransaction(xid);
|
|
||||||
globalLockManager.begin(xid);
|
globalLockManager.begin(xid);
|
||||||
recordid rid;
|
recordid rid;
|
||||||
rid.page = 0;
|
rid.page = 0;
|
||||||
|
@ -31,38 +30,24 @@ void * pageWorkerThread(void * j) {
|
||||||
if(rw) {
|
if(rw) {
|
||||||
// readlock
|
// readlock
|
||||||
int locked = 0;
|
int locked = 0;
|
||||||
// try_ret(0) {
|
|
||||||
if(LLADD_DEADLOCK == globalLockManager.readLockPage(xid, m)) {
|
if(LLADD_DEADLOCK == globalLockManager.readLockPage(xid, m)) {
|
||||||
k = 0;
|
k = 0;
|
||||||
assert(compensation_error() == LLADD_DEADLOCK);
|
assert(compensation_error() == LLADD_DEADLOCK);
|
||||||
compensation_clear_error();
|
compensation_clear_error();
|
||||||
globalLockManager.abort(xid);
|
globalLockManager.abort(xid);
|
||||||
deadlocks++;
|
deadlocks++;
|
||||||
printf("-");
|
|
||||||
locked = 1;
|
locked = 1;
|
||||||
}
|
}
|
||||||
// } end_ret();
|
|
||||||
} else {
|
} else {
|
||||||
// writelock
|
|
||||||
// int locked = 0;
|
|
||||||
// begin_action_ret(NULL, NULL, 0) {
|
|
||||||
|
|
||||||
if(LLADD_DEADLOCK == globalLockManager.writeLockPage(xid, m)) {
|
if(LLADD_DEADLOCK == globalLockManager.writeLockPage(xid, m)) {
|
||||||
k = 0;
|
k = 0;
|
||||||
globalLockManager.abort(xid);
|
globalLockManager.abort(xid);
|
||||||
deadlocks++;
|
deadlocks++;
|
||||||
printf("-");
|
|
||||||
int err = compensation_error();
|
int err = compensation_error();
|
||||||
assert(err == LLADD_DEADLOCK);
|
assert(err == LLADD_DEADLOCK);
|
||||||
compensation_clear_error();
|
compensation_clear_error();
|
||||||
}
|
}
|
||||||
/* if(locked) {
|
|
||||||
int err = compensation_error();
|
|
||||||
assert(err == LLADD_DEADLOCK);
|
|
||||||
compensation_clear_error();
|
|
||||||
} */
|
|
||||||
// } end_action_ret(0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +61,6 @@ void * pageWorkerThread(void * j) {
|
||||||
void * ridWorkerThread(void * j) {
|
void * ridWorkerThread(void * j) {
|
||||||
|
|
||||||
int xid = *(int*)j;
|
int xid = *(int*)j;
|
||||||
//startTransaction(xid);
|
|
||||||
globalLockManager.begin(xid);
|
globalLockManager.begin(xid);
|
||||||
recordid rid;
|
recordid rid;
|
||||||
rid.page = 0;
|
rid.page = 0;
|
||||||
|
@ -90,26 +74,20 @@ void * ridWorkerThread(void * j) {
|
||||||
if(rw) {
|
if(rw) {
|
||||||
// readlock
|
// readlock
|
||||||
|
|
||||||
// begin_action_ret(NULL, NULL, 0) {
|
|
||||||
if(LLADD_DEADLOCK == globalLockManager.readLockRecord(xid, rid)) {
|
if(LLADD_DEADLOCK == globalLockManager.readLockRecord(xid, rid)) {
|
||||||
k = 0;
|
k = 0;
|
||||||
globalLockManager.abort(xid);
|
globalLockManager.abort(xid);
|
||||||
deadlocks++;
|
deadlocks++;
|
||||||
printf("-");
|
|
||||||
}
|
}
|
||||||
// } end_action_ret(0);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// writelock
|
// writelock
|
||||||
|
|
||||||
// begin_action_ret(NULL, NULL, 0) {
|
|
||||||
if(LLADD_DEADLOCK == globalLockManager.writeLockRecord(xid, rid)) {
|
if(LLADD_DEADLOCK == globalLockManager.writeLockRecord(xid, rid)) {
|
||||||
k = 0;
|
k = 0;
|
||||||
globalLockManager.abort(xid);
|
globalLockManager.abort(xid);
|
||||||
deadlocks++;
|
deadlocks++;
|
||||||
printf("-");
|
|
||||||
}
|
}
|
||||||
// } end_action_ret(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +107,7 @@ START_TEST(recordidLockManagerTest) {
|
||||||
|
|
||||||
pthread_t workers[THREAD_COUNT];
|
pthread_t workers[THREAD_COUNT];
|
||||||
int i;
|
int i;
|
||||||
|
printf("The following numbers are deadlock counts for each thread.\n");
|
||||||
for(i = 0; i < THREAD_COUNT; i++) {
|
for(i = 0; i < THREAD_COUNT; i++) {
|
||||||
int *j = malloc(sizeof(int));
|
int *j = malloc(sizeof(int));
|
||||||
*j = i;
|
*j = i;
|
||||||
|
@ -147,6 +126,7 @@ START_TEST(pageLockManagerTest) {
|
||||||
|
|
||||||
pthread_t workers[THREAD_COUNT];
|
pthread_t workers[THREAD_COUNT];
|
||||||
int i;
|
int i;
|
||||||
|
printf("The following numbers are deadlock counts for each thread.\n");
|
||||||
for(i = 0; i < THREAD_COUNT; i++) {
|
for(i = 0; i < THREAD_COUNT; i++) {
|
||||||
int *j = malloc(sizeof(int));
|
int *j = malloc(sizeof(int));
|
||||||
*j = i;
|
*j = i;
|
||||||
|
|
Loading…
Reference in a new issue