From: bdemsky Date: Thu, 16 Jul 2009 10:49:53 +0000 (+0000) Subject: bug fix X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5dcb22ca0faf376481234289d3001cb00b9f732c;p=IRC.git bug fix --- diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Client.java b/Robust/src/Benchmarks/SingleTM/Vacation/Client.java index f2e03f80..e0bc915e 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Client.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Client.java @@ -143,8 +143,7 @@ public class Client extends Thread { int r = randomPtr.posrandom_generate() % 100; int action = selectAction(r, percentUser); - switch (action) { - case ACTION_MAKE_RESERVATION: { + if(action==ACTION_MAKE_RESERVATION) { int maxPrices[]=new int[NUM_RESERVATION_TYPE]; int maxIds[]=new int[NUM_RESERVATION_TYPE]; maxPrices[0]=-1; @@ -166,24 +165,18 @@ public class Client extends Thread { int t = types[n]; int id = ids[n]; int price = -1; - switch (t) { - case RESERVATION_CAR: + if (t==RESERVATION_CAR) { if (managerPtr.manager_queryCar(id) >= 0) { price = managerPtr.manager_queryCarPrice(id); } - break; - case RESERVATION_FLIGHT: + } else if (t==RESERVATION_FLIGHT) { if (managerPtr.manager_queryFlight(id) >= 0) { price = managerPtr.manager_queryFlightPrice(id); } - break; - case RESERVATION_ROOM: + } else if (t==RESERVATION_ROOM) { if (managerPtr.manager_queryRoom(id) >= 0) { price = managerPtr.manager_queryRoomPrice(id); } - break; - default: - //assert(0); } if (price > maxPrices[t]) { maxPrices[t] = price; @@ -204,10 +197,7 @@ public class Client extends Thread { managerPtr.manager_reserveRoom(customerId, maxIds[RESERVATION_ROOM]); } } - break; - } - - case ACTION_DELETE_CUSTOMER: { + } else if (action==ACTION_DELETE_CUSTOMER) { int customerId = randomPtr.posrandom_generate() % queryRange + 1; atomic { int bill = managerPtr.manager_queryCustomerBill(customerId); @@ -215,10 +205,7 @@ public class Client extends Thread { managerPtr.manager_deleteCustomer(customerId); } } - break; - } - - case ACTION_UPDATE_TABLES: { + } else if (action==ACTION_UPDATE_TABLES) { int numUpdate = randomPtr.posrandom_generate() % numQueryPerTransaction + 1; int n; for (n = 0; n < numUpdate; n++) { @@ -236,42 +223,25 @@ public class Client extends Thread { int doAdd = ops[n]; if (doAdd==1) { int newPrice = prices[n]; - switch (t) { - case RESERVATION_CAR: + if (t==RESERVATION_CAR) { managerPtr.manager_addCar(id, 100, newPrice); - break; - case RESERVATION_FLIGHT: + } else if (t==RESERVATION_FLIGHT) { managerPtr.manager_addFlight(id, 100, newPrice); - break; - case RESERVATION_ROOM: + } else if (t==RESERVATION_ROOM) { managerPtr.manager_addRoom(id, 100, newPrice); - break; - default: - //assert(0); } } else { /* do delete */ - switch (t) { - case RESERVATION_CAR: + if (t==RESERVATION_CAR) { managerPtr.manager_deleteCar(id, 100); - break; - case RESERVATION_FLIGHT: + } else if (t==RESERVATION_FLIGHT) { managerPtr.manager_deleteFlight(id); - break; - case RESERVATION_ROOM: + } else if (t==RESERVATION_ROOM) { managerPtr.manager_deleteRoom(id, 100); - break; - default: - //assert(0); } } } } - break; } - - default: - //assert(0); - } /* switch (action) */ } /* for i */ Barrier.enterBarrier(); } diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Customer.java b/Robust/src/Benchmarks/SingleTM/Vacation/Customer.java index 22daf531..e55499e5 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Customer.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Customer.java @@ -129,7 +129,7 @@ public class Customer { boolean status = reservationInfoListPtr.remove(findReservationInfo); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART15"); System.exit(-1); } diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Manager.java b/Robust/src/Benchmarks/SingleTM/Vacation/Manager.java index cab10aa0..409a8531 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Manager.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Manager.java @@ -118,7 +118,7 @@ public class Manager { if (reservationPtr.numTotal == 0) { boolean status = tablePtr.remove(id); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART7"); System.exit(-1); } } else { @@ -241,7 +241,7 @@ public class Manager { // assert(customerPtr != null); status = customerTablePtr.insert(customerId, customerPtr); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART8"); System.exit(-1); } @@ -282,20 +282,20 @@ public class Manager { reservationInfoPtr =(Reservation_Info)it.dataPtr; reservationPtr = (Reservation)reservationTables[reservationInfoPtr.type].find(reservationInfoPtr.id); if (reservationPtr == null) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART9"); System.exit(-1); } status = reservationPtr.reservation_cancel(); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART10"); System.exit(-1); } } status = customerTablePtr.remove(customerId); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART11"); System.exit(-1); } return true; @@ -464,7 +464,7 @@ public class Manager { /* Undo previous successful reservation */ boolean status = reservationPtr.reservation_cancel(); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART12"); System.exit(-1); } return false; @@ -548,7 +548,7 @@ public class Manager { /* Undo previous successful cancellation */ boolean status = reservationPtr.reservation_make(); if (!status) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART13"); System.exit(-1); } return false; diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Reservation.java b/Robust/src/Benchmarks/SingleTM/Vacation/Reservation.java index 8157d1fc..a2098e1c 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Reservation.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Reservation.java @@ -76,6 +76,7 @@ public class Reservation { this.numFree=numTotal; this.numTotal=numTotal; this.price=price; + checkReservation(); } int id; @@ -92,30 +93,30 @@ public class Reservation { public void checkReservation() { int numUsed = this.numUsed; if (numUsed < 0) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART1"); System.exit(-1); } int numFree = this.numFree; if (numFree < 0) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART2"); System.exit(-1); } int numTotal = this.numTotal; if (numTotal < 0) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART3"); System.exit(-1); } if ((numUsed + numFree) != numTotal) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART4"); System.exit(-1); } int price = this.price; if (price < 0) { - System.out.println("TMRESTART"); + System.out.println("TMRESTART5"); System.exit(-1); } } @@ -134,6 +135,7 @@ public class Reservation { numFree+=num; numTotal+=num; + checkReservation(); return true; } @@ -149,6 +151,7 @@ public class Reservation { } numUsed++; numFree--; + checkReservation(); return true; } @@ -164,7 +167,8 @@ public class Reservation { } numUsed--; numFree++; - return false; + checkReservation(); + return true; } @@ -180,6 +184,7 @@ public class Reservation { } this.price=newPrice; + checkReservation(); return true; } diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java b/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java index 30bd2690..dcc16f6a 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java @@ -76,6 +76,8 @@ public class Vacation { * displayUsage * ============================================================================= */ + public Vacation() { + } public static void displayUsage (String appName) { System.out.println("Usage: %s [options]\n"+ appName); @@ -196,19 +198,14 @@ public class Vacation { int id = ids[i]; int num = ((randomPtr.posrandom_generate() % 5) + 1) * 100; int price = ((randomPtr.posrandom_generate() % 5) * 10) + 50; - switch(t) { - case 0: + if (t==0) { status=managerPtr.manager_addCar(id, num, price); - break; - case 1: + } else if (t==1) { status=managerPtr.manager_addFlight(id, num, price); - break; - case 2: + } else if (t==2) { status=managerPtr.manager_addRoom(id, num, price); - break; - case 3: + } else if (t==3) { status=managerPtr.manager_addCustomer(id); - break; } //assert(status); } diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/makefile b/Robust/src/Benchmarks/SingleTM/Vacation/makefile index 094862a8..46d38625 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/makefile +++ b/Robust/src/Benchmarks/SingleTM/Vacation/makefile @@ -1,6 +1,6 @@ MAINCLASS=Vacation SRC=tmpVacation.java tmpClient.java tmpManager.java tmpRBTree.java \ -../../../ClassLibrary/JavaSTM/Barrier.java +../../../ClassLibrary/JavaSTM/Barrier.java ../common/Random.java include ../common/Makefile.flags