From 27a3668364e68ad6608d98a694b7a4a7aa7723c4 Mon Sep 17 00:00:00 2001 From: navid Date: Fri, 21 Nov 2008 09:52:41 +0000 Subject: [PATCH] *** empty log message *** --- Robust/Transactions/NativeFunctions.h | 22 + Robust/Transactions/NativeFuntions.c | 26 + Robust/Transactions/README.txt | 14 + .../src/TransactionalIO/Utilities/Range.java | 108 ++ .../src/TransactionalIO/benchmarks/Main.java | 152 ++ .../benchmarks/MainforLocks.java | 142 ++ .../benchmarks/StatisticsWrapper.java | 17 + .../TransactionalIO/benchmarks/benchmark.java | 270 +++ .../benchmarks/customhandler.java | 62 + .../benchmarks/lockthread1.java | 86 + .../TransactionalIO/benchmarks/thread1.java | 489 +++++ .../TransactionalIO/benchmarks/thread2.java | 38 + .../TransactionalIO/benchmarks/thread3.java | 55 + .../TransactionalIO/benchmarks/thread4.java | 53 + .../core/BlockDataStructure.java | 107 ++ .../src/TransactionalIO/core/CustomLock.java | 62 + .../TransactionalIO/core/CustomThread.java | 113 ++ .../src/TransactionalIO/core/Defaults.java | 73 + .../core/ExtendedTransaction.java | 971 ++++++++++ .../core/FileBlockManager.java | 34 + .../core/GlobalINodeState.java | 118 ++ .../TransactionalIO/core/GlobalOffset.java | 52 + .../src/TransactionalIO/core/INode.java | 61 + .../core/ManagerRepository.java | 36 + .../core/TransactionLocalFileAttributes.java | 77 + .../core/TransactionalFile.java | 1592 +++++++++++++++++ .../core/TransactionalFileWrapperFactory.java | 67 + .../src/TransactionalIO/core/Wrapper.java | 115 ++ .../TransactionalIO/core/WriteOperations.java | 82 + .../exceptions/AbortedException.java | 56 + .../exceptions/GracefulException.java | 48 + .../exceptions/PanicException.java | 69 + .../exceptions/SnapshotException.java | 58 + .../interfaces/BlockAccessModesEnum.java | 14 + .../interfaces/ContentionManager.java | 36 + .../interfaces/FileAccessModesEum.java | 17 + .../interfaces/OffsetDependency.java | 15 + .../interfaces/TransactionStatu.java | 23 + .../interfaces/TransactionalProgram.java | 15 + Robust/Transactions/dstm2/-b | 0 .../dstm2/build-before-profiler.xml | 70 + Robust/Transactions/dstm2/build.xml | 71 + Robust/Transactions/dstm2/hs_err_pid27741.log | 273 +++ Robust/Transactions/dstm2/hs_err_pid27828.log | 273 +++ Robust/Transactions/dstm2/hs_err_pid27887.log | 271 +++ Robust/Transactions/dstm2/manifest.mf | 3 + .../dstm2/src/dstm2/AtomicArray.java | 181 ++ .../dstm2/src/dstm2/ContentionManager.java | 77 + .../dstm2/src/dstm2/Defaults.java | 65 + Robust/Transactions/dstm2/src/dstm2/Main.java | 179 ++ .../Transactions/dstm2/src/dstm2/Thread.java | 610 +++++++ .../dstm2/src/dstm2/Transaction.java | 291 +++ .../Transactions/dstm2/src/dstm2/atomic.java | 47 + .../dstm2/exceptions/GracefulException.java | 48 + .../exceptions/MemoryAbortedException.java | 56 + .../src/dstm2/exceptions/PanicException.java | 69 + .../dstm2/exceptions/SnapshotException.java | 58 + .../dstm2/src/dstm2/factory/Adapter.java | 77 + .../src/dstm2/factory/AtomicFactory.java | 417 +++++ .../dstm2/src/dstm2/factory/BaseFactory.java | 309 ++++ .../dstm2/src/dstm2/factory/ClassLoader.java | 56 + .../dstm2/src/dstm2/factory/Copyable.java | 41 + .../dstm2/src/dstm2/factory/CopyableDef.java | 40 + .../dstm2/src/dstm2/factory/Factory.java | 48 + .../dstm2/src/dstm2/factory/Property.java | 95 + .../dstm2/src/dstm2/factory/Releasable.java | 45 + .../src/dstm2/factory/SequentialFactory.java | 140 ++ .../dstm2/src/dstm2/factory/Snapable.java | 58 + .../src/dstm2/manager/AggressiveManager.java | 58 + .../src/dstm2/manager/BackoffManager.java | 101 ++ .../dstm2/src/dstm2/manager/BaseManager.java | 83 + .../src/dstm2/manager/EruptionManager.java | 101 ++ .../src/dstm2/manager/GreedyManager.java | 68 + .../dstm2/src/dstm2/manager/KarmaManager.java | 84 + .../dstm2/manager/KindergartenManager.java | 82 + .../src/dstm2/manager/PriorityManager.java | 61 + .../dstm2/src/dstm2/util/Random.java | 255 +++ Robust/Transactions/libkooni.so | Bin 0 -> 26643 bytes 78 files changed, 10306 insertions(+) create mode 100644 Robust/Transactions/NativeFunctions.h create mode 100644 Robust/Transactions/NativeFuntions.c create mode 100644 Robust/Transactions/README.txt create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Range.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/Main.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/MainforLocks.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/StatisticsWrapper.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/customhandler.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/lockthread1.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/thread1.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/thread2.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/thread3.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/thread4.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/BlockDataStructure.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomLock.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomThread.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Defaults.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/FileBlockManager.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalINodeState.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalOffset.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/INode.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ManagerRepository.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionLocalFileAttributes.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFileWrapperFactory.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Wrapper.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/core/WriteOperations.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/AbortedException.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/GracefulException.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/PanicException.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/SnapshotException.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/BlockAccessModesEnum.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/ContentionManager.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/FileAccessModesEum.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/OffsetDependency.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionStatu.java create mode 100644 Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionalProgram.java create mode 100644 Robust/Transactions/dstm2/-b create mode 100644 Robust/Transactions/dstm2/build-before-profiler.xml create mode 100644 Robust/Transactions/dstm2/build.xml create mode 100644 Robust/Transactions/dstm2/hs_err_pid27741.log create mode 100644 Robust/Transactions/dstm2/hs_err_pid27828.log create mode 100644 Robust/Transactions/dstm2/hs_err_pid27887.log create mode 100644 Robust/Transactions/dstm2/manifest.mf create mode 100644 Robust/Transactions/dstm2/src/dstm2/AtomicArray.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/ContentionManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/Defaults.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/Main.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/Thread.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/Transaction.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/atomic.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/exceptions/GracefulException.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/exceptions/MemoryAbortedException.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/exceptions/PanicException.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/exceptions/SnapshotException.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Adapter.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/AtomicFactory.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/BaseFactory.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/ClassLoader.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Copyable.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/CopyableDef.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Factory.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Property.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Releasable.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/SequentialFactory.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/factory/Snapable.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/AggressiveManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/BackoffManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/BaseManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/EruptionManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/GreedyManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/KarmaManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/KindergartenManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/manager/PriorityManager.java create mode 100644 Robust/Transactions/dstm2/src/dstm2/util/Random.java create mode 100755 Robust/Transactions/libkooni.so diff --git a/Robust/Transactions/NativeFunctions.h b/Robust/Transactions/NativeFunctions.h new file mode 100644 index 00000000..f5ea3fe3 --- /dev/null +++ b/Robust/Transactions/NativeFunctions.h @@ -0,0 +1,22 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __dstm2_file_factory_TransactionalFileWrapperFactory__ +#define __dstm2_file_factory_TransactionalFileWrapperFactory__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jlong JNICALL Java_TransactionalIO_core_TransactionalFileWrapperFactory_getINodeNative (JNIEnv *env, jobject, jstring); + +JNIEXPORT jint JNICALL Java_TransactionalIO_core_TransactionalFile_nativepread (JNIEnv *env, jobject object2, jbyteArray buff, jlong offset, jint size, jobject object); + +JNIEXPORT jint JNICALL Java_TransactionalIO_core_ExtendedTransaction_nativepwrite (JNIEnv *env, jobject object2, jbyteArray buff, jlong offset, jint size, jobject object); +#ifdef __cplusplus +} +#endif + +#endif /* __HellWorld__ */ diff --git a/Robust/Transactions/NativeFuntions.c b/Robust/Transactions/NativeFuntions.c new file mode 100644 index 00000000..0be35d8d --- /dev/null +++ b/Robust/Transactions/NativeFuntions.c @@ -0,0 +1,26 @@ +/* + * File: HelloWorld.cpp + * Author: navid + * + * Created on September 3, 2008, 2:17 PM + */ + + #include + #include + #include + #include "NativeFunctions.h" + + JNIEXPORT jlong JNICALL Java_TransactionalFileWrapperFactory_getINodeNative + (JNIEnv *env, jobject obj, jstring filename) + { + struct stat status_buf; + jlong inodenum; + // stat("/home/navid/myfile.txt",&status_buf); + char *str = (*env)->GetStringUTFChars(env, filename, 0); + printf("File Name is: %s \n", str); + stat(str,&status_buf); + printf("Inode number is: %lu \n", status_buf.st_ino); + inodenum = status_buf.st_ino; + return inodenum; + } + diff --git a/Robust/Transactions/README.txt b/Robust/Transactions/README.txt new file mode 100644 index 00000000..b76d336d --- /dev/null +++ b/Robust/Transactions/README.txt @@ -0,0 +1,14 @@ +To run the integrated system run dstm2 with +java -jar "your_path" +with dstm2.benchmark.Main_for_Book_BenchMArk as the main class +and "-b" "dstm2.benchmark.FinancialTransaction" as the argument to main function + + +For the TransactionalIO the main class is TransactionalIO.benchmarks.Main +and no argumets are required. + + +libkooni.so path should be passed as the filepath for nativefunctions in TransactionalIO.core.ExtendedTransaction and TransactionalIO.core.TransactionalFile. + +Eventually there is gonna be java class for these files namely TransactionalIO.core.TransactionalFile. + diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Range.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Range.java new file mode 100644 index 00000000..0de34e3d --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Range.java @@ -0,0 +1,108 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.Utilities; + + +/** + * + * @author navid + */ +public class Range implements Comparable { + + private long start; + private long end; + + public Range() { + } + + public Range(long start, long end) { + this.start = start; + this.end = end; + } + + public long getEnd() { + return end; + } + + public void setEnd(long end) { + this.end = end; + } + + public long getStart() { + return start; + } + + public void setStart(long start) { + this.start = start; + } + + public Range intersection(Range secondrange) { + if ((secondrange.start <= this.start) && (this.start <= secondrange.end)) { + return new Range(this.start, Math.min(this.end, secondrange.end)); + } else if ((secondrange.start <= this.end) && (this.end <= secondrange.end)) { + return new Range(Math.max(this.start, secondrange.start), this.end); + } else if ((this.start <= secondrange.start) && (secondrange.end <= this.end)) { + return new Range(secondrange.start, secondrange.end); + } else { + return null; + } + } + + public boolean hasIntersection(Range secondrange) { + if ((secondrange.start <= this.start) && (this.start <= secondrange.end)) { + return true; + } else if ((secondrange.start <= this.end) && (this.end <= secondrange.end)) { + return true; + } else if ((this.start <= secondrange.start) && (secondrange.end <= this.end)) { + return true; + } else { + return false; + } + } + + + public boolean includes(Range secondrange) { + if (this.start <= secondrange.start && secondrange.end <= this.end) { + return true; + } else { + return false; + } + } + + public Range[] minus(Range[] intersectedranges, int size) { + Range[] tmp = new Range[size + 1]; + + int counter = 0; + if (this.start < intersectedranges[0].start) { + tmp[counter] = new Range(this.start, intersectedranges[0].start); + counter++; + } + for (int i = 1; i < size; i++) { + tmp[counter] = new Range(intersectedranges[i - 1].end, intersectedranges[i].start); + counter++; + } + if (this.end > intersectedranges[size - 1].end) { + tmp[counter] = new Range(intersectedranges[size - 1].end, this.end); + counter++; + } + Range[] result = new Range[counter]; + for (int i = 0; i < counter; i++) { + result[i] = tmp[i]; + } + return result; + } + + public int compareTo(Object arg0) { + + Range tmp = (Range) arg0; + if (this.start < tmp.start) { + return -1; + } else if (this.start == tmp.start) { + return 0; + } else { + return 1; + } + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/Main.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/Main.java new file mode 100644 index 00000000..7797e908 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/Main.java @@ -0,0 +1,152 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.benchmarks; + +import TransactionalIO.core.CustomThread; +import TransactionalIO.core.ExtendedTransaction; +import TransactionalIO.core.TransactionalFile; +import java.io.File; +import java.util.Iterator; +import java.util.TreeMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author navid + */ +public class Main { + + public static void main(String args[]){ + try { + // benchmark.init(); + + + // for (int i=0; i<100; i++){ + benchmark.init(); + //System.out.println( + long starttime = System.nanoTime(); + /* thread1 tr1 = new thread1(); + thread2 tr2 = new thread2(); + thread3 tr3 = new thread3(); + thread4 tr4 = new thread4();*/ + /*TransactionalIO tr2 = new TransactionalIO(); + TransactionalIO tr3 = new TransactionalIO(); + CustomThread ct1 = new CustomThread(tr1); + CustomThread ct2 = new CustomThread(tr2);*/ + + /* CustomThread ct1 = new CustomThread(new thread1('a', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct2 = new CustomThread(new thread1('b', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct3 = new CustomThread(new thread1('c', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct4= new CustomThread(new thread1('d', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct5 = new CustomThread(new thread1('e', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct6 = new CustomThread(new thread1('f', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct7 = new CustomThread(new thread1('g', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct8 = new CustomThread(new thread1('h', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct9 = new CustomThread(new thread1('i',new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct10 = new CustomThread(new thread1('j', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct11 = new CustomThread(new thread1('k', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct12 = new CustomThread(new thread1('l', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct13 = new CustomThread(new thread1('m', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct14 = new CustomThread(new thread1('n', new TransactionalFile("/home/navid/output.text", "rw"))); + + CustomThread ct15 = new CustomThread(new thread1('o', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct16 = new CustomThread(new thread1('p', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct17 = new CustomThread(new thread1('q', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct18 = new CustomThread(new thread1('r', new TransactionalFile("/home/navid/output.text", "rw"))); + + // CustomThread ct15 = new CustomThread(tr2); + CustomThread ct19 = new CustomThread(new thread1('s', new TransactionalFile("/home/navid/output.text", "rw"))); + CustomThread ct20 = new CustomThread(new thread1('t', new TransactionalFile("/home/navid/output.text", "rw")));*/ + + + CustomThread ct1 = new CustomThread(new thread1('a')); + CustomThread ct2 = new CustomThread(new thread1('b')); + CustomThread ct3 = new CustomThread(new thread1('c')); + CustomThread ct4= new CustomThread(new thread1('d')); + CustomThread ct5 = new CustomThread(new thread1('e')); + CustomThread ct6 = new CustomThread(new thread1('f')); + CustomThread ct7 = new CustomThread(new thread1('g')); + CustomThread ct8 = new CustomThread(new thread1('h')); + CustomThread ct9 = new CustomThread(new thread1('i')); + CustomThread ct10 = new CustomThread(new thread1('j')); + CustomThread ct11 = new CustomThread(new thread1('k')); + CustomThread ct12 = new CustomThread(new thread1('l')); + CustomThread ct13 = new CustomThread(new thread1('m')); + CustomThread ct14 = new CustomThread(new thread1('n')); + + CustomThread ct15 = new CustomThread(new thread1('o')); + CustomThread ct16 = new CustomThread(new thread1('p')); + CustomThread ct17 = new CustomThread(new thread1('q')); + CustomThread ct18 = new CustomThread(new thread1('r')); + + // CustomThread ct15 = new CustomThread(tr2); + CustomThread ct19 = new CustomThread(new thread1('s')); + CustomThread ct20 = new CustomThread(new thread1('t')); + + + //CustomThread ct4 = new CustomThread(tr3); + + // CustomThread ct5 = new CustomThread(tr4); + // CustomThread ct6 = new CustomThread(tr2); + + // CustomThread ct4 = new CustomThread(tr2); + ct1.runner.join(); + ct2.runner.join(); + ct3.runner.join(); + ct4.runner.join(); + ct5.runner.join(); + ct6.runner.join(); + ct7.runner.join(); + ct8.runner.join(); + ct9.runner.join(); + ct10.runner.join(); + ct11.runner.join(); + ct12.runner.join(); + ct13.runner.join(); + ct14.runner.join(); + + + + ct15.runner.join(); + ct16.runner.join(); + ct17.runner.join(); + ct18.runner.join(); + ct19.runner.join(); + + ct20.runner.join(); + + long endttime = System.nanoTime(); + // System.out.println(endttime - starttime); + System.out.println((endttime - starttime)/1000000); + //} + /* TreeMap msgs = new TreeMap(); + Iterator it = benchmark.transacctions.iterator(); + while(it.hasNext()){ + ExtendedTransaction tr = (ExtendedTransaction) it.next(); + msgs.putAll(tr.msg); + } + + Iterator it2 = msgs.keySet().iterator(); + while(it2.hasNext()){ + Long time = (Long) it2.next(); + System.out.print(time +" " + msgs.get(time)); + }*/ + int index =97; + for (int j = 0; j < 26; j++) { + ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close(); + } + // } + + //System.out.println(Thread.currentThread().getName()); + } catch (InterruptedException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + //System.out.println(Thread.currentThread().getName()); + + + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/MainforLocks.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/MainforLocks.java new file mode 100644 index 00000000..e74f4978 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/MainforLocks.java @@ -0,0 +1,142 @@ + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.benchmarks; + +import TransactionalIO.core.TransactionalFile; +import java.io.FileNotFoundException; +import java.io.RandomAccessFile; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author navid + */ +public class MainforLocks { + + public static void main(String args[]){ + try { + RandomAccessFile file = new RandomAccessFile("/home/navid/randomwords.text", "rw"); + benchmark.init(); + long starttime = System.nanoTime(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread1 = new lockthread1(file, 'a'); + // benchmark.filelock.writeLock().unlock(); + +// benchmark.filelock.writeLock().lock(); + lockthread1 thread2 = new lockthread1(file, 'b'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread3 = new lockthread1(file, 'c'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread4 = new lockthread1(file, 'd'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread5 = new lockthread1(file, 'e'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread6 = new lockthread1(file, 'f'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread7 = new lockthread1(file, 'g'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread8 = new lockthread1(file, 'h'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread9 = new lockthread1(file, 'i'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread10 = new lockthread1(file, 'j'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread11 = new lockthread1(file, 'k'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread12 = new lockthread1(file, 'l'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread13 = new lockthread1(file, 'm'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread14 = new lockthread1(file, 'n'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread15 = new lockthread1(file, 'o'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread16 = new lockthread1(file, 'p'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread17 = new lockthread1(file, 'q'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread18 = new lockthread1(file, 'r'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread19 = new lockthread1(file, 's'); + // benchmark.filelock.writeLock().unlock(); + + // benchmark.filelock.writeLock().lock(); + lockthread1 thread20 = new lockthread1(file, 't'); + // benchmark.filelock.writeLock().unlock(); + + thread1.join(); + thread2.join(); + thread3.join(); + thread4.join(); + thread5.join(); + thread6.join(); + thread7.join(); + thread8.join(); + thread9.join(); + thread10.join(); + thread11.join(); + thread12.join(); + thread13.join(); + thread14.join(); + thread15.join(); + thread16.join(); + thread17.join(); + thread18.join(); + thread19.join(); + thread20.join(); + + long endttime = System.nanoTime(); + System.out.println(endttime - starttime); + System.out.println((endttime - starttime) / 1000000); + int index =97; + for (int j = 0; j < 26; j++) { + ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close(); + } + } catch (InterruptedException ex) { + Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex); + } catch (FileNotFoundException ex) { + Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex); + } + + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/StatisticsWrapper.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/StatisticsWrapper.java new file mode 100644 index 00000000..5fcf21cd --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/StatisticsWrapper.java @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.benchmarks; + +/** + * + * @author navid + */ +public class StatisticsWrapper { + + public static int totalcommitted; + public static int totalaborted; + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java new file mode 100644 index 00000000..b611e141 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java @@ -0,0 +1,270 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.benchmarks; + +import TransactionalIO.core.Defaults; +import TransactionalIO.core.TransactionalFile; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.logging.Level; +import java.util.logging.Logger; + + +/** + * + * @author navid + */ +public class benchmark { + static public HashMap TransactionalFiles = new HashMap(); + static public HashMap hotwords = new HashMap(); + static public HashMap names = new HashMap(); + static public HashMap reversenames = new HashMap(); + static int count = 0; + public static String msg = new String(); + public static ReentrantLock lock = new ReentrantLock(); + public static Vector transacctions = new Vector(); + public static ReentrantLock filelock = new ReentrantLock(); + public static Map m; + public static Map m2; + public static Map m3; + public static Map m4; + public static String[] stocks; + + + public benchmark() { + + } + + private static void preparenamelist(){ + try { + byte[] data = new byte[1]; + char[] name = new char[20]; + RandomAccessFile file = new RandomAccessFile("/home/navid/namelist.text", "rw"); + RandomAccessFile file2 = new RandomAccessFile("/home/navid/financialtransaction.text", "rw"); + RandomAccessFile file3 = new RandomAccessFile("/home/navid/accountbalance.text", "rw"); + + + stocks = new String[20]; + stocks[0] = "Yahoo"; + stocks[1] = "Google"; + stocks[2] = "Microsoft"; + stocks[3] = "Broadcom"; + stocks[4] = "Sun"; + stocks[5] = "Qualcom"; + stocks[6] = "Intel"; + stocks[7] = "WaMU"; + stocks[8] = "BoA"; + stocks[9] = "IMU"; + stocks[10] = "BMW"; + stocks[11] = "Nokia"; + stocks[12] = "Motorolla"; + stocks[13] = "Samsung"; + stocks[14] = "TMobile"; + stocks[15] = "ATT"; + stocks[16] = "PRops"; + stocks[17] = "Asia"; + stocks[18] = "LOLa"; + stocks[19] = "Brita"; + /* boolean hh = false; + boolean found = false; + while (true) { + + if (found){ + System.out.println(file4.getFilePointer()-1); + file4.seek(file4.getFilePointer()-1); + file4.write(' '); + file4.write(stocks[(int)(Math.random()*10)].getBytes()); + file4.write('\n'); + } + if (hh) + break; + found = false; + data[0] = 'a'; + while (data[0] != '\n') { + int tt =0; + tt = file4.read(data); + found = true; + if (tt == -1) { + hh = true; + break; + } + } + }*/ + + boolean flag = false; + boolean done = false; + int wordcounter = 0; + int counter =0; + while(true){ + if (flag) + break; + if (done){ + // System.out.println("At " + wordcounter + " inserted " +String.copyValueOf(name, 0, counter)); + m3.put(Integer.valueOf(wordcounter), String.copyValueOf(name, 0, counter)); + m4.put(String.copyValueOf(name, 0, counter), Integer.valueOf(wordcounter)); + wordcounter++; + done = false; + } + counter = 0; + data[0] = 'a'; + while (data[0] != '\n') { + int res; + res = file.read(data); + if (res == -1) { + flag = true; + break; + } + //System.out.println((char)data[0]); + if (!(Character.isLetter((char) data[0]))) { + continue; + } + name[counter] = (char)data[0]; + done = true; + counter++; + } + } + + + /* counter = 0; + while (counter <30000) { + int index1 = (int)(Math.random()*50); + int stocktrade = (int)(Math.random()*100); + while (stocktrade == 0) + stocktrade = (int)(Math.random()*100); + int index2 = (int)(Math.random()*50); + while (index2 == index1) + index2 = (int)(Math.random()*50); + //System.out.println(index); + String towrite = (String)m3.get(Integer.valueOf(index1)) + " "; + towrite += String.valueOf(stocktrade) + " "; + towrite += (String)m3.get(Integer.valueOf(index2)) + " "; + towrite += stocks[(int)(Math.random()*20)] + "\n"; + + file2.write(towrite.getBytes()); + // System.out.println(towrite); + counter++; + }*/ + // for (int i=0; i<50*Defaults.FILEFRAGMENTSIZE; i++) + //file3.write(''); + + + for (int i=0; i<50; i++){ + String towrite = (String)m3.get(Integer.valueOf(i)) +"\n"; + for (int j=0; j readers; + private Vector blockreaders; + + public static enum MODE {READ, WRITE, READ_WRITE}; + private MODE accessmode; + + protected BlockDataStructure(INode inode, int blocknumber) { + version = new AtomicInteger(0); + //lock = new ReentrantReadWriteLock(); + blockreaders = new Vector(); + lock = new ReentrantReadWriteLock(); + this.inode = inode; + this.blocknumber = blocknumber; + referncount = 0; + owner = null; + } + + public Vector getReaders() { + return blockreaders; + } + + public void setReaders(Vector readers) { + this.blockreaders = readers; + } + + public ReentrantReadWriteLock getLock() { + return lock; + } + + public void setLock(ReentrantReadWriteLock lock) { + this.lock = lock; + } + + public synchronized ExtendedTransaction getOwner() { + return owner; + } + + public synchronized void setOwner(ExtendedTransaction owner) { + this.owner = owner; + } + + public INode getInode() { + return inode; + } + + public void setInode(INode inode) { + this.inode = inode; + } + + public int getBlocknumber() { + return blocknumber; + } + + public void setBlocknumber(int blocknumber) { + this.blocknumber = blocknumber; + } + + public AtomicInteger getVersion() { + return version; + } + + public void setVersion(AtomicInteger version) { + this.version = version; + } + + public MODE getAccessmode() { + return accessmode; + } + + public void setAccessmode(MODE accessmode) { + this.accessmode = accessmode; + } + + public synchronized int getReferncount() { + return referncount; + } + + public synchronized void setReferncount(int referncount) { + this.referncount = referncount; + } + + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomLock.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomLock.java new file mode 100644 index 00000000..265716bf --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomLock.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + + +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.benchmarks.thread1; +import TransactionalIO.interfaces.TransactionalProgram; + +/** + * + * @author navid + */ +public class CustomLock implements Runnable{ + + private static ThreadLocal transactioncontainer = new ThreadLocal(); + private TransactionalProgram ioprogram; + private static ThreadLocal/**/ program = new ThreadLocal(); + private ExtendedTransaction transaction; + public Thread runner; + + + public CustomLock(TransactionalProgram ioprogram) { + this.ioprogram = ioprogram; + transaction = new ExtendedTransaction(); + runner = new Thread(this); + runner.start(); + } + + public static void setTransaction(ExtendedTransaction transaction){ + transactioncontainer.set(transaction); + } + + public static ExtendedTransaction getTransaction(){ + return (ExtendedTransaction) transactioncontainer.get(); + } + + public static void setProgram(TransactionalProgram transaction){ + program.set(transaction); + } + + public static TransactionalProgram getProgram(){ + return (TransactionalProgram) program.get(); + } + + + public void run() { + setTransaction(transaction); + setProgram(ioprogram); + synchronized(benchmark.lock){ + benchmark.transacctions.add(transaction); + } +// System.out.println(Thread.currentThread().getName()); + ioprogram.execute(); + transaction.prepareCommit(); + transaction.commitChanges(); + } + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomThread.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomThread.java new file mode 100644 index 00000000..429f34c0 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/CustomThread.java @@ -0,0 +1,113 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.interfaces.TransactionalProgram; +import java.io.IOException; +import java.util.Vector; + +/** + * + * @author navid + */ +public class CustomThread implements Runnable{ + + + private static ThreadLocal transactioncontainer = new ThreadLocal(); + private static ThreadLocal onAbort = new ThreadLocal(); + private TransactionalProgram ioprogram; + private static ThreadLocal/**/ program = new ThreadLocal(); + private ExtendedTransaction transaction; + public Thread runner; + + + + public CustomThread(TransactionalProgram ioprogram) { + this.ioprogram = ioprogram; + runner = new Thread(this); + runner.start(); + } + + + + /* public static void setTransaction(ExtendedTransaction transaction){ + transactioncontainer.set(transaction); + } + + public static ExtendedTransaction getTransaction(){ + return (ExtendedTransaction) transactioncontainer.get(); + }*/ + + public static void setProgram(TransactionalProgram transaction){ + program.set(transaction); + } + + public static TransactionalProgram getProgram(){ + return (TransactionalProgram) program.get(); + } + + public static Vector getonAbort(){ + return (Vector) onAbort.get(); + } + + public static void setonAbort(Vector s){ + onAbort.set(s); + } + + + public void run() { + + setProgram(ioprogram); + // setonAbort(new Vector()); +// System.out.println(Thread.currentThread().getName()); + while (true){ + try{ + /* getonAbort().add(new terminateHandler() { + public void cleanup() { + synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" KEWL"); + } + } + }); + */ + + Wrapper.Initialize(null); + // transaction = new ExtendedTransaction(); + // setTransaction(transaction); + synchronized(benchmark.lock){ + benchmark.transacctions.add(Wrapper.getTransaction()); + } + ioprogram.execute(); + Wrapper.prepareIOCommit(); + + Wrapper.commitIO(); + break; + } + catch (AbortedException e){ + /* Iterator it = getonAbort().iterator(); + while(it.hasNext()) { + terminateHandler th = (terminateHandler)it.next(); + th.cleanup(); + } + getonAbort().clear();*/ + + + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" retried"); + }*/ + + } + finally{ + Wrapper.getTransaction().unlockAllLocks(); + } + } + } + + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Defaults.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Defaults.java new file mode 100644 index 00000000..cf8d075e --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Defaults.java @@ -0,0 +1,73 @@ +package TransactionalIO.core; + +/* + * Defaults.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + + + +/** + * + * @author Maurice Herlihy + */ + + +public class Defaults { + /** + * how many threads + **/ + public static final int THREADS = 1; + /** + * benchmark duration in milliseconds + **/ + public static final int TIME = 10000; + /** + * uninterpreted arg passed to benchmark + **/ + public static final int EXPERIMENT = 100; + /** + * fully-qualified contention manager name + **/ + public static final String MANAGER = "dstm2.manager.BackoffManager"; + /** + * fully-qualified factory name + **/ + public static final String FACTORY = "dstm2.factory.shadow.Factory"; + /** + * fully-qualified adapter name + **/ + public static final String ADAPTER = "dstm2.factory.shadow.Adapter";; + + public static final int FILEFRAGMENTSIZE= 1024; + + public static final boolean READWRITECONFLIT = true; + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java new file mode 100644 index 00000000..42b757ab --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java @@ -0,0 +1,971 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.core; + + + + + +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.benchmarks.customhandler; +import TransactionalIO.benchmarks.customhandler; +import TransactionalIO.interfaces.BlockAccessModesEnum; +import TransactionalIO.interfaces.ContentionManager; +import TransactionalIO.interfaces.TransactionStatu; +//import dstm2.file.managers.BaseManager; +import java.awt.event.ActionListener; +import java.beans.EventHandler; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.FileDescriptor; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author navid + */ +public class ExtendedTransaction implements TransactionStatu { + + + private native int nativepwrite(byte buff[], long offset, int size, FileDescriptor fd); + + { + System.load("/home/navid/libkooni.so"); + } + + private boolean flag = true; + public TransactionStatu memorystate; + private PropertyChangeSupport changes = new PropertyChangeSupport(this); + public int starttime; + public int endtime; + + public TreeMap msg = new TreeMap(); + public int numberofwrites; + public int numberofreads; + + public enum Status {ABORTED, ACTIVE, COMMITTED}; + private boolean writesmerged = true; + + //private Vector heldoffsetlocks; + private Vector heldoffsetlocks; + + //private Vector heldblocklocks; + private Vector heldblocklocks; + + //private HashMap> AccessedFiles; + private HashMap AccessedFiles; + + + //private HashMap > accessedBlocks; + private HashMap accessedBlocks; + + //private HashMap LocaltoGlobalMappings; + private HashMap GlobaltoLocalMappings; + + public HashMap merge_for_writes_done; + + + + + private HashMap writeBuffer; + + private ContentionManager contentionmanager; + private /*volatile*/ Status status; + + private int id; + + + + public ExtendedTransaction() { + // super(); + // id = Integer.valueOf(Thread.currentThread().getName().substring(7)); + heldblocklocks = new Vector() ; + heldoffsetlocks= new Vector(); + AccessedFiles = new HashMap(); + GlobaltoLocalMappings = new HashMap/**/(); + writeBuffer = new HashMap(); + status = Status.ACTIVE; + accessedBlocks = new HashMap(); + merge_for_writes_done = new HashMap(); + writesmerged = true; + // setContentionmanager(new BaseManager()); + // beginTransaction(); + + } + + public ExtendedTransaction(TransactionStatu memorystate){ + this(); + /* heldblocklocks = new Vector() ; + heldoffsetlocks= new Vector(); + AccessedFiles = new HashMap(); + GlobaltoLocalMappings = new HashMap(); + writeBuffer = new HashMap(); + status = Status.ACTIVE; + accessedBlocks = new HashMap(); + merge_for_writes_done = new HashMap(); + writesmerged = true;*/ + this.memorystate = memorystate ; + } + + private int invokeNativepwrite(byte buff[], long offset, int size, RandomAccessFile file) { + try { + //System.out.println(buff.length); + // System.out.println(offset); + return nativepwrite(buff, offset, buff.length, file.getFD()); + } catch (IOException ex) { + + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + return -1; + } + + } + + public void beginTransaction(){ + this.addPropertyChangeListener(new customhandler(Status.ABORTED)); + } + + + + + public void abort() { + synchronized(this){ + // Status oldst = getStatus(); + /* synchronized(benchmark.lock){ + System.out.println("be ga raftim 0"); + }*/ + this.status = Status.ABORTED; + if (this.memorystate !=null && !(this.memorystate).isAborted()){ + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" be ga raftim 1 file"); + }*/ + this.memorystate.abortThisSystem(); + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " be ga raftim 2 file"); + }*/ + } + // Thread[] group = new Thread[30]; + // Thread.currentThread().enumerate(group); + // group[this.id].interrupt(); + /*synchronized(benchmark.lock){ + System.out.println("/////////////"); + System.out.println(Thread.currentThread() + " " +Thread.currentThread().enumerate(group)); + System.out.println(Thread.currentThread() + " " +group[0]); + System.out.println(Thread.currentThread() + " " +group[1]); + System.out.println(Thread.currentThread() + " " +group[2]); + System.out.println("/////////////"); + }*/ + + + // this.changes.firePropertyChange("status", oldst, Status.ABORTED); + } + + } + + public Status getStatus() { + return status; + } + + public boolean isActive() { + return this.getStatus() == Status.ACTIVE; + } + + + public boolean isAborted() { + return this.getStatus() == Status.ABORTED; + } + + public ContentionManager getContentionmanager() { + return contentionmanager; + } + + public void setContentionmanager(ContentionManager contentionmanager) { + this.contentionmanager = contentionmanager; + } + + + public HashMap getWriteBuffer() { + return writeBuffer; + } + + public HashMap getAccessedFiles() { + return AccessedFiles; + } + + public boolean isWritesmerged() { + return writesmerged; + } + + public void setWritesmerged(boolean writesmerged) { + this.writesmerged = writesmerged; + } + + + + + + + public HashMap getGlobaltoLocalMappings() { + return GlobaltoLocalMappings; + } + + public HashMap getAccessedBlocks() { + return accessedBlocks; + } + + + public ContentionManager getBlockContentionManager(){ + return ManagerRepository.getBlockcm(); + } + + public ContentionManager getOffsetContentionManager(){ + return ManagerRepository.getOffsetcm(); + } + + public TreeMap getSortedFileAccessMap(HashMap hmap) { + /*TreeMap sortedMap = new TreeMap(hmap); + return sortedMap;*/ + return new TreeMap(hmap); + } + + + public void setStatus(Status st){ + Status oldst = getStatus(); + this.status = st; + this.changes.firePropertyChange("status", oldst, st); + } + + + + + public void addFile(TransactionalFile tf/*, TransactionLocalFileAttributes tmp*/) { + + + /* if (tf.appendmode) { + this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.APPEND); + } else if (tf.writemode) { + this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.READ_WRITE); + } else { + this.addtoFileAccessModeMap(tf.getInode(), FileAccessModesEum.READ); + }*/ + // System.out.println("dsadssasadssa"); + + tf.lockOffset(this); + + //tf.offsetlock.lock(); + TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(tf.getCommitedoffset().getOffsetnumber()/*, tf.getInodestate().commitedfilesize.get()*/); + //this.heldoffsetlocks.remove(tf.offsetlock); + tf.offsetlock.unlock(); + + Vector dummy; + + if (AccessedFiles.containsKey(tf.getInode())){ + dummy = (Vector) AccessedFiles.get(tf.getInode()); + } + else{ + dummy = new Vector(); + AccessedFiles.put(tf.getInode(), dummy); + } + + + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum()); + dummy.add(tf); + GlobaltoLocalMappings.put(tf, tmp); + merge_for_writes_done.put(tf.getInode(), Boolean.TRUE); + + + + //} + + } + + + public boolean lockOffsets() { /// Locking offsets for File Descriptors + + + TreeMap hm = getSortedFileAccessMap(AccessedFiles); + Iterator iter = hm.keySet().iterator(); + + while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) { + INode key = (INode) iter.next(); + + Vector vec = (Vector) AccessedFiles.get(key); + Collections.sort(vec); + Iterator it = vec.iterator(); + while (it.hasNext()){ + TransactionalFile value = (TransactionalFile) it.next(); + while (this.getStatus() ==Status.ACTIVE){ + //if (value.offsetlock.tryLock()) { + value.offsetlock.lock(); + + // synchronized(value.getCommitedoffset()){ + // value.getCommitedoffset().setOffsetOwner(this); + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Locked the offset lock in commit for file " + value.getInode() + " from descriptor "+ value.getSequenceNum() +"\n"); + heldoffsetlocks.add(value.offsetlock); + + //else + // getContentionmanager().resolveConflict(this, value.getCommitedoffset()); + break; + //} + } + if (this.getStatus() != Status.ACTIVE){ + + + return false; + } + } + // outercounter++; + } + if (this.getStatus() != Status.ACTIVE){ + + + return false; + } + return true; + } + + /*public boolean commit() { /// Locking offsets for File Descriptors + + Map hm = getSortedFileAccessMap(FilesAccesses); + //lock phase + Iterator iter = hm.keySet().iterator(); + TransactionLocalFileAttributes value; + while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) { + INode key = (INode) iter.next(); + value = (TransactionLocalFileAttributes) hm.get(key); + synchronized(value.getCurrentcommitedoffset()){ + if (value.offsetlock.tryLock()) { + value.getCurrentcommitedoffset().setOffsetOwner(this); + heldblocklocks.add(value.offsetlock); + Iterator it = value.getCurrentcommitedoffset().getOffsetReaders().iterator(); // for in-place aborting visible readers strategy + while (it.hasNext()) + { + ExtendedTransaction tr = (ExtendedTransaction) it.next(); + tr.abort(); + } + } + } + } + getOffsetContentionManager().resolveConflict(this, value.getCurrentcommitedoffset().getOffsetOwner()); + } + return true; + } */ + + /*public boolean commit() { /// Locking offsets for File Descriptors with checking strategy + + Map hm = getSortedFileAccessMap(FilesAccesses); + //lock phase + Iterator iter = hm.keySet().iterator(); + TransactionLocalFileAttributes value; + while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) { + INode key = (INode) iter.next(); + value = (TransactionLocalFileAttributes) hm.get(key); + + if (value.isValidatelocaloffset()) { + if (value.getCopylocaloffset() == value.currentcommitedoffset.getOffsetnumber()) { + value.offsetlock.lock(); + heldoffsetlocks.add(value.offsetlock); + if (!(value.getCopylocaloffset() == value.currentcommitedoffset.getOffsetnumber())) { + unlockAllLocks(); + return false; + } + } else { + unlockAllLocks(); + return false; + } + } else { + value.offsetlock.lock(); + heldoffsetlocks.add(value.offsetlock); + } + } + }*/ + + + + + public boolean lockBlock(BlockDataStructure block, BlockAccessModesEnum mode/*, GlobalINodeState adapter, BlockAccessModesEnum mode, int expvalue, INode inode, TransactionLocalFileAttributes tf*/) { + + + //boolean locked = false; + Lock lock; + + + + if (mode == BlockAccessModesEnum.READ){ + lock = block.getLock().readLock(); + + + } + else { + + lock = block.getLock().writeLock(); + + } + + while (this.getStatus() == Status.ACTIVE) { + //synchronized(block){ + + // if (lock.tryLock()) { + lock.lock(); + // synchronized(benchmark.lock){ + // System.out.println(Thread.currentThread() + " Lock the block lock for " + lock +" number " + block.getBlocknumber()); + // } + heldblocklocks.add(lock); + // block.setOwner(this); + return true; + // } + + + //getContentionmanager().resolveConflict(this, block); + } + + return false; + } + /* + public boolean lockBlock(BlockDataStructure block, Adapter adapter, BlockAccessModesEnum mode, int expvalue) { // from here for visible readers strategy + while (this.getStatus() == Status.ACTIVE) { + if (lock.tryLock()) { + Thread.onAbortOnce(new Runnable() { + + public void run() { + lock.unlock(); + } + }); + + heldblocklocks.add(lock); + + synchronized (adapter) { + block.setOwner(this); + // Iterator it = block.getReaders().iterator(); + // while (it.hasNext()) + // { + // ExtendedTransaction tr = (ExtendedTransaction) it.next(); + // tr.abort(); + // } + } + + return true; + } else { + getBlockContentionManager().resolveConflict(this, block.getOwner()); + } + } + return false;*/ + + + /* + public boolean lockBlock(BlockDataStructure block, Adapter adapter, BlockAccessModesEnum mode, int expvalue) { // versioning strat + while (this.getStatus() == Status.ACTIVE) { + if (lock.tryLock()) { + Thread.onAbortOnce(new Runnable() { + + public void run() { + lock.unlock(); + } + }); + + heldblocklocks.add(lock); + if (mode != BlockAccessModesEnum.WRITE) { egy + if (block.getVersion().get() != expvalue) { + unlockAllLocks(); + return false; + } + } + synchronized (adapter) { + block.setOwner(this); + } + + return true; + } else { + getContentionManager().resolveConflict(this, block.getOwner()); + } + } + return false; + }*/ + + public void prepareCommit() { + if (this.status != Status.ACTIVE) + throw new AbortedException(); + + boolean ok = true; + if (!lockOffsets()) + { +// unlockAllLocks(); + // this.msg.put(System.nanoTime(),Thread.currentThread().getName() + " Aborted \n"); + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Aborted in prepare commit\n"; + }*/ + //Thread.currentThread().stop(); + throw new AbortedException(); + } + + + /////////////////////////// + + + Map hm = getWriteBuffer(); + + Iterator iter = hm.keySet().iterator(); + WriteOperations value; + Vector vec = new Vector(); + while (iter.hasNext() && (this.getStatus() == Status.ACTIVE) && ok) { + //int expvalue = 0; + + INode key = (INode) iter.next(); + vec = (Vector) hm.get(key); + Collections.sort(vec); + Iterator it = vec.iterator(); + while (it.hasNext()){ + + value = (WriteOperations) it.next(); + if (value.isUnknownoffset()){ + + long start; + long end; + + //synchronized(value.getOwnertransactionalFile().getCommitedoffset()){ + start = value.getRange().getStart() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber(); + end = value.getRange().getEnd() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber(); + if (value.getBelongingto().isUnknown_inital_offset_for_write()){ + value.getBelongingto().setLocaloffset(value.getBelongingto().getLocaloffset() - value.getBelongingto().getCopylocaloffset() + value.getOwnertransactionalFile().getCommitedoffset().getOffsetnumber()); + value.getBelongingto().setUnknown_inital_offset_for_write(false); + } + + //} + // System.out.println("start write " + start); + /// System.out.println("end write " + end); + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(start); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(start, value.getRange().getEnd() - value.getRange().getStart()); + + TreeMap sset; + if (this.getAccessedBlocks().get(key) != null){ + sset = (TreeMap) this.getAccessedBlocks().get(key); + } + + else{ + sset = new TreeMap(); + this.getAccessedBlocks().put(key, sset); + } + + + for (int i = startblock; i <= targetblock; i++) { + if (sset.containsKey(Integer.valueOf(i))){ + if (sset.get(Integer.valueOf(i)) != BlockAccessModesEnum.WRITE) + sset.put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE); + } + else + sset.put(Integer.valueOf(i), BlockAccessModesEnum.WRITE); + + // tt.add(Integer.valueOf(i)); + } + + value.getRange().setStart(start); + value.getRange().setEnd(end); + + // System.out.println(Thread.currentThread().); + // System.out.println(value.getRange().getStart()); + // System.out.println(value.getRange().getEnd()); + // System.out.println("---------------"); + //this.getAccessedBlocks().put(value.getOwnertransactionalFile().getInode(), sset); + } + } + + } + + Iterator it = this.getAccessedBlocks().keySet().iterator(); + while (it.hasNext() && (this.getStatus() == Status.ACTIVE)) { + INode inode = (INode) it.next(); + GlobalINodeState inodestate = TransactionalFileWrapperFactory.getTateransactionalFileINodeState(inode); + TreeMap vec2 = (TreeMap) this.getAccessedBlocks().get(inode); + Iterator iter2 = vec2.keySet().iterator(); + while(iter2.hasNext()){ + Integer num = (Integer) iter2.next(); + + //BlockDataStructure blockobj = (BlockDataStructure) inodestate.lockmap.get(num); + BlockDataStructure blockobj; + // if (((BlockAccessModesEnum)vec2.get(num)) == BlockAccessModesEnum.WRITE){ + blockobj = inodestate.getBlockDataStructure(num); + // } + // else + // blockobj = (BlockDataStructure) inodestate.lockmap.get(num); + + ok = this.lockBlock(blockobj, (BlockAccessModesEnum)vec2.get(num)); + if (ok == false) + break; + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Locked the Block Number " + blockobj.getBlocknumber() +" for " + inode + "\n"; + }*/ + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Locked the Block Number " + blockobj.getBlocknumber() + " for file " + inode + "\n"); + } + } + + if (this.getStatus() != Status.ACTIVE){ + // unlockAllLocks(); + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Aborted \n"); + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Aborted \n"; + }*/ + // Thread.currentThread().stop(); + throw new AbortedException(); + } + abortAllReaders(); + + // } + //expvalue = ((Integer) value.getBlockversions().get(it)).intValue(); //for versioning strategy + /*if (!(value.isValidatelocaloffset())) { + if (((BlockAccessModesEnum) (value.getAccesedblocks().get(blockno))) != BlockAccessModesEnum.WRITE) { //versioning strategy + + /if (blockobj.getVersion().get() == expvalue) { + + ok = this.lock(blockobj, value.adapter, (BlockAccessModesEnum) (value.getAccesedblocks().get(blockno)), expvalue); + if (ok == false) { + // unlockAllLocks(); + break; + } + } else { + ok = false; + break; + } + } else { + + ok = this.lock(blockobj, value.adapter, (BlockAccessModesEnum) (value.getAccesedblocks().get(blockno)), expvalue); + if (ok == false) { + break; + } + } + } + + + if (!(ok)) { + unlockAllLocks(); + throw new AbortedException(); + }*/ + } + + public void commitChanges(){ + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " is committing \n"); + + + + //synchronized(benchmark.lock){ + // System.out.println(Thread.currentThread().getName() + " is commiting"); + //} + + + Map hm = getWriteBuffer(); + Iterator iter = hm.keySet().iterator(); + Iterator it; + WriteOperations writeop; + Vector vec; + while (iter.hasNext() && (this.getStatus() == Status.ACTIVE)) { + INode key = (INode) iter.next(); + + vec = (Vector) hm.get(key); + Collections.sort(vec); + it = vec.iterator(); + while (it.hasNext()){ + + + //value = (WriteOperations) it.next(); + // writeop = (WriteOperations) writeBuffer.get(key); + writeop = (WriteOperations) it.next(); + // System.out.println(writeop); + Byte[] data = new Byte[(int) (writeop.getRange().getEnd() - writeop.getRange().getStart())]; + byte[] bytedata = new byte[(int) (writeop.getRange().getEnd() - writeop.getRange().getStart())]; + data = (Byte[]) writeop.getData(); + + for (int i = 0; i < data.length; i++) { + bytedata[i] = data[i]; + } + + // try { + // + // writeop.getOwnertransactionalFile().file.seek(writeop.getRange().getStart()); + // System.out.println(Thread.currentThread() + " range " + writeop.getRange().getStart()); + // writeop.getOwnertransactionalFile().file.write(bytedata); + invokeNativepwrite(bytedata, writeop.getRange().getStart(), bytedata.length, writeop.getOwnertransactionalFile().file); + // System.out.println(Thread.currentThread() + " " + bytedata); + + // } catch (IOException ex) { + // Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex); + // } + // + + } + } + + /*if (((FileAccessModesEum) (this.FilesAccessModes.get(key))) == FileAccessModesEum.APPEND) { + try { + Range range = (Range) value.getWrittendata().firstKey(); + + + //synchronized(value.adapter){ + //value.f.seek(value.adapter.commitedfilesize.get()); + value.f.seek(value.getFilelength()); + //} + + Byte[] data = new Byte[(int) (range.getEnd() - range.getStart())]; + byte[] bytedata = new byte[(int) (range.getEnd() - range.getStart())]; + data = (Byte[]) value.getWrittendata().get(range); + + for (int i = 0; i < data.length; i++) { + bytedata[i] = data[i]; + } + value.f.write(bytedata); + + } catch (IOException ex) { + Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex); + } + + } else if (((FileAccessModesEum) (this.FilesAccessModes.get(key))) == FileAccessModesEum.READ) { + continue; + } + else if (value.relocatablewrite && value.getContinious_written_data() != null){ + + + } + else if (!(value.getNon_Speculative_Writtendata().isEmpty())) { + int tobeaddedoffset = 0; + + if (value.isValidatelocaloffset()) { + tobeaddedoffset = 0; + } else { + tobeaddedoffset = (int) (value.getCurrentcommitedoffset().getOffsetnumber() - value.getCopylocaloffset()); + } + Iterator it = value.getNon_Speculative_Writtendata().keySet().iterator(); + int counter = 0; + while (it.hasNext() && (this.getStatus() == Status.ACTIVE)) { + try { + Range range = (Range) it.next(); + + + value.f.seek(range.getStart() + tobeaddedoffset); + + Byte[] data = new Byte[(int) (range.getEnd() - range.getStart())]; + byte[] bytedata = new byte[(int) (range.getEnd() - range.getStart())]; + data = (Byte[]) value.getNon_Speculative_Writtendata().get(range); + + for (int i = 0; i < data.length; i++) { + bytedata[i] = data[i]; + } + value.f.write(bytedata); + counter++; + + } catch (IOException ex) { + Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex); + } + } + } else { + continue; + } + } + + + iter = hm.keySet().iterator(); + while (iter.hasNext() ) { + INode key = (INode) iter.next(); + value = (TransactionLocalFileAttributes) hm.get(key); + Iterator it = value.getAccesedblocks().keySet().iterator(); + + while (it.hasNext()) { + Integer blockno = (Integer) it.next(); + synchronized (value.adapter) { + //BlockDataStructure blockobj = (BlockDataStructure) value.adapter.lockmap.get(blockno); + //blockobj.getVersion().getAndIncrement(); for versioning strategy + //value.getCurrentcommitedoffset().setOffsetnumber(value.getLocaloffset()); + //value.adapter.commitedfilesize.getAndSet(value.getFilelength()); + } + } + }*/ + Iterator k = GlobaltoLocalMappings.keySet().iterator(); + while (k.hasNext()){ + TransactionalFile trf = (TransactionalFile) (k.next()); + // synchronized(trf.getCommitedoffset()){ + trf.getCommitedoffset().setOffsetnumber(((TransactionLocalFileAttributes)GlobaltoLocalMappings.get(trf)).getLocaloffset()); + /*synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " KIRIR " +GlobaltoLocalMappings.get(trf).getLocaloffset()); + }*/ + // } + } + //unlockAllLocks(); + + } + + public void unlockAllLocks() { + Iterator it = heldblocklocks.iterator(); + + while (it.hasNext()) { + + Lock lock = (Lock) it.next(); + lock.unlock(); + + /*synchronized(benchmark.lock){ + System.out.println(Thread.currentThread().getName() + " Released the block lock for " + lock); + }*/ + } + heldblocklocks.clear(); + + it = heldoffsetlocks.iterator(); + while (it.hasNext()) { + ReentrantLock lock = (ReentrantLock) it.next(); + lock.unlock(); + // synchronized(benchmark.lock){ + // System.out.println(Thread.currentThread().getName() + " Released the offset lock for "+ lock +"\n"); + // } + } + heldoffsetlocks.clear(); + } + + public void abortAllReaders(){ + TreeMap hm = getSortedFileAccessMap(AccessedFiles); + //lock phase + Iterator iter = hm.keySet().iterator(); + TransactionalFile value; + while (iter.hasNext()) { + INode key = (INode) iter.next(); + Vector vec = (Vector) AccessedFiles.get(key); + Iterator it = vec.iterator(); + while (it.hasNext()) + { + + value = (TransactionalFile)it.next(); + + //value = (TransactionalFile) hm.get(key); + //System.out.println(value.getCommitedoffset().getOffsetReaders()); + + Iterator it2 = value.getCommitedoffset().getOffsetReaders().iterator(); // for visible readers strategy + while ( it2.hasNext()) + { + + ExtendedTransaction tr = (ExtendedTransaction) it2.next(); + if (tr != this) + tr.abort(); + } + value.getCommitedoffset().getOffsetReaders().clear(); + //} + } + + + + TreeMap vec2; + if (accessedBlocks.get(key) != null){ + vec2 = (TreeMap) accessedBlocks.get(key); + } + else{ + vec2 = new TreeMap(); + + } + GlobalINodeState inodestate = TransactionalFileWrapperFactory.getTateransactionalFileINodeState(key); + Iterator it2 = vec2.keySet().iterator(); + + while (it2.hasNext()) + { + + Integer num = (Integer)it2.next(); + if (vec2.get(num) != BlockAccessModesEnum.READ) + { + BlockDataStructure blockobj = (BlockDataStructure) inodestate.getBlockDataStructure(num);//lockmap.get(num); + Iterator it4 = blockobj.getReaders().iterator(); // from here for visible readers strategy + + while (it4.hasNext()) + { + + ExtendedTransaction tr = (ExtendedTransaction) it4.next(); + if (this != tr) + tr.abort(); + } + blockobj.getReaders().clear(); + + } + } + + + + + /* SortedSet sst = (SortedSet) this.getAccessedBlocks().get(key); + Iterator it3 = sst.iterator(); + while (it3.hasNext()){ + Integer num = (Integer)it.next(); + BlockDataStructure blockobj = (BlockDataStructure) value.getInodestate().lockmap.get(num); + Iterator it4 = blockobj.getReaders().iterator(); // from here for visible readers strategy + while (it4.hasNext()) + { + ExtendedTransaction tr = (ExtendedTransaction) it3.next(); + tr.abort(); + } + + }*/ + + } + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.changes.addPropertyChangeListener("status",listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.changes.removePropertyChangeListener("status",listener); + } + + public TransactionStatu getOtherSystem() { + return memorystate; + } + + public void setOtherSystem(TransactionStatu othersystem) { + memorystate = othersystem; + } + + public Vector getHeldblocklocks() { + return heldblocklocks; + } + + public void setHeldblocklocks(Vector heldblocklocks) { + this.heldblocklocks = heldblocklocks; + } + + public Vector getHeldoffsetlocks() { + return heldoffsetlocks; + } + + public void setHeldoffsetlocks(Vector heldoffsetlocks) { + this.heldoffsetlocks = heldoffsetlocks; + } + + public void abortThisSystem() { + abort(); + } + + public boolean isCommitted() { + if (this.status == Status.COMMITTED) + return true; + + return false; + + } + + + +} + + + + + + diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/FileBlockManager.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/FileBlockManager.java new file mode 100644 index 00000000..bff7234d --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/FileBlockManager.java @@ -0,0 +1,34 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.core; + +//import Defaults; + + + + + + + + + +/** + * + * @author navid + */ +public class FileBlockManager { + + public static long getFragmentIndexofTheFile(long filesize) { + return (filesize / Defaults.FILEFRAGMENTSIZE); + } + + public static int getCurrentFragmentIndexofTheFile(long start) { + return (int) ((start / Defaults.FILEFRAGMENTSIZE)); + } + + public static int getTargetFragmentIndexofTheFile(long start, long offset) { + return (int) (((offset + start) / Defaults.FILEFRAGMENTSIZE)); + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalINodeState.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalINodeState.java new file mode 100644 index 00000000..f3705a9e --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalINodeState.java @@ -0,0 +1,118 @@ +/* + * Adapter.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ +package TransactionalIO.core; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Obstruction-free atomic object implementation. Visible reads. + * Support snapshots and early release. + * @author Navid Farri + */ +public class GlobalINodeState { + + // public HashMap lockmap; + public HashMap lockmap; + private ConcurrentHashMap conlockmap = new ConcurrentHashMap(); + + public AtomicLong commitedfilesize = new AtomicLong(); + private ExtendedTransaction writer; + public int seqNum = 0; + private INode inode; + + public GlobalINodeState() { + } + + + + + protected GlobalINodeState(INode inode, long length) { + writer = null; + lockmap = new HashMap(); + + commitedfilesize.set(length); + this.inode = inode; + } + + + + + public AtomicLong getCommitedfilesize() { + return commitedfilesize; + } + + public void setCommitedfilesize(AtomicLong commitedfilesize) { + this.commitedfilesize = commitedfilesize; + } + + public ExtendedTransaction getWriter() { + return writer; + } + + public void setWriter(ExtendedTransaction writer) { + this.writer = writer; + } + + public BlockDataStructure getBlockDataStructure(Integer blocknumber) { + /* synchronized (lockmap) { + if (lockmap.containsKey(blocknumber)) { + return ((BlockDataStructure) (lockmap.get(blocknumber))); + } else { + BlockDataStructure tmp = new BlockDataStructure(inode, blocknumber); + lockmap.put(blocknumber, tmp); + return tmp; + } + } + }*/ + BlockDataStructure rec = (BlockDataStructure)conlockmap.get(blocknumber); + if (rec == null) { + // record does not yet exist + BlockDataStructure newRec = new BlockDataStructure(inode, blocknumber); + rec = (BlockDataStructure)conlockmap.putIfAbsent(blocknumber, newRec); + if (rec == null) { + // put succeeded, use new value + rec = newRec; + } + } + return rec; +} + + + + + +} + diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalOffset.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalOffset.java new file mode 100644 index 00000000..f32ffe3b --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalOffset.java @@ -0,0 +1,52 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +import java.util.Vector; + +/** + * + * @author navid + */ +public class GlobalOffset { + private long offsetnumber; + //private Vector offsetReaders; + private Vector offsetReaders = new Vector(); + private ExtendedTransaction offsetOwner; + + public GlobalOffset(long offsetnumber) { + this.offsetnumber = offsetnumber; + } + + + public long getOffsetnumber() { + return offsetnumber; + } + + public ExtendedTransaction getOffsetOwner(){ + return offsetOwner; + } + + public void setOffsetOwner(ExtendedTransaction ex){ + offsetOwner = ex; + } + + public void setOffsetnumber(long offsetnumber) { + this.offsetnumber = offsetnumber; + } + + public Vector getOffsetReaders() { + return offsetReaders; + } + + public void setOffsetReaders(Vector offsetReaders) { + this.offsetReaders = offsetReaders; + } + + + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/INode.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/INode.java new file mode 100644 index 00000000..e5a1f826 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/INode.java @@ -0,0 +1,61 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +/** + * + * @author navid + */ +public class INode implements Comparable{ + + private String filepath; + private long number; + + + public INode(long number) { + this.number = number; + } + + public INode(long number, String filepath) { + this(number); + this.filepath = filepath; + } + + public String getFilepath() { + return filepath; + } + + public void setFilepath(String filepath) { + this.filepath = filepath; + } + + + + public long getNumber() { + return number; + } + + public void setNumber(long number) { + this.number = number; + } + + public int compareTo(Object arg0) { + INode other = (INode) arg0; + if (this.getNumber() < other.getNumber()) + return -1; + else if (this.getNumber() > other.getNumber()) + return 1; + else{ + System.out.println("Logical Eroor Two Inodes cannot have the same number"); + return 0; + } + + } + + + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ManagerRepository.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ManagerRepository.java new file mode 100644 index 00000000..79e2efd9 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ManagerRepository.java @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +import TransactionalIO.interfaces.ContentionManager; + + +/** + * + * @author navid + */ +public class ManagerRepository { + private static ContentionManager blockcm; + private static ContentionManager offsetcm; + + public synchronized static ContentionManager getBlockcm() { + return blockcm; + } + + public synchronized static void setBlockcm(ContentionManager blockcm) { + ManagerRepository.blockcm = blockcm; + } + + public synchronized static ContentionManager getOffsetcm() { + return offsetcm; + } + + public synchronized static void setOffsetcm(ContentionManager offsetcm) { + ManagerRepository.offsetcm = offsetcm; + } + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionLocalFileAttributes.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionLocalFileAttributes.java new file mode 100644 index 00000000..3da69130 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionLocalFileAttributes.java @@ -0,0 +1,77 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.core; + + +import TransactionalIO.interfaces.OffsetDependency; +import java.io.RandomAccessFile; + +/** + * + * @author navid + */ +public class TransactionLocalFileAttributes { + + + private INode inode; + public boolean to_be_created = false; + RandomAccessFile f; + OffsetDependency offsetdependency; + private long copylocaloffset; + private boolean unknown_inital_offset_for_write = true; + private long localoffset; + private long localsize; + + public TransactionLocalFileAttributes(long initialoffset/*, long initialsize*/){ + localoffset = initialoffset; + copylocaloffset = initialoffset; + //copylocaloffset = 0; + unknown_inital_offset_for_write = true; + offsetdependency = OffsetDependency.NO_ACCESS; + //localsize = initialsize; + } + + public long getCopylocaloffset() { + return copylocaloffset; + } + + public void setCopylocaloffset(long copylocaloffset) { + this.copylocaloffset = copylocaloffset; + } + + public long getLocalsize() { + return localsize; + } + + public void setLocalsize(long localsize) { + this.localsize = localsize; + } + + + public OffsetDependency getOffsetdependency() { + return offsetdependency; + } + + public void setOffsetdependency(OffsetDependency offsetdependency) { + this.offsetdependency = offsetdependency; + } + + public boolean isUnknown_inital_offset_for_write() { + return unknown_inital_offset_for_write; + } + + public void setUnknown_inital_offset_for_write(boolean unknown_inital_offset_for_write) { + this.unknown_inital_offset_for_write = unknown_inital_offset_for_write; + } + + public long getLocaloffset() { + return localoffset; + } + + public void setLocaloffset(long localoffset) { + this.localoffset = localoffset; + } + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java new file mode 100644 index 00000000..72cdf445 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java @@ -0,0 +1,1592 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.core; + + + +import TransactionalIO.Utilities.Range; +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.exceptions.PanicException; +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.core.ExtendedTransaction.Status; +import TransactionalIO.interfaces.BlockAccessModesEnum; +import TransactionalIO.interfaces.OffsetDependency; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import java.io.File; +import java.io.FileDescriptor; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.util.Collections; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Vector; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.Level; +import java.util.logging.Logger; +import sun.misc.ConditionLock; + +/** + * + * @author navid + */ + + +public class TransactionalFile implements Comparable{ + + + private native int nativepread(byte buff[], long offset, int size, FileDescriptor fd); + + { + System.load("/home/navid/libkooni.so"); + } + + + public RandomAccessFile file; + private INode inode; + private int sequenceNum = 0; + public static int currenSeqNumforInode = 0; + /* public AtomicLong commitedoffset; + public AtomicLong commitedfilesize;*/ + public boolean to_be_created = false; + public boolean writemode = false; + public boolean appendmode = false; + public ReentrantLock offsetlock; + private GlobalOffset committedoffset; + private GlobalINodeState inodestate ; + + + public TransactionalFile(String filename, String mode) { + + + File f = new File(filename); + + if ((!(f.exists()))) { + to_be_created = true; + file = null; + + } else { + + try { + + offsetlock = new ReentrantLock(); + file = new RandomAccessFile(f, mode); + } catch (FileNotFoundException ex) { + + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } + + } + inode = TransactionalFileWrapperFactory.getINodefromFileName(filename); + inodestate = TransactionalFileWrapperFactory.createTransactionalFile(inode, filename, mode); + + + sequenceNum = inodestate.seqNum; + inodestate.seqNum++; + + + + + + if (mode.equals("rw")) { + writemode = true; + } else if (mode.equals("a")) { + appendmode = true; + } + + if (inodestate != null) { + synchronized (inodestate) { + try { + // if (!(to_be_created)) { + // } else { + // adapter.commitedfilesize.set(0); + // } + + if (!appendmode) { + //commitedoffset.setOffsetnumber(0); + committedoffset = new GlobalOffset(0); + } else { + committedoffset = new GlobalOffset(file.length()); + } + + } catch (IOException ex) { + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + + } + + private int invokeNativepread(byte buff[], long offset, int size) { + try { + return nativepread(buff, offset, size, file.getFD()); + } catch (IOException ex) { + + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + return -1; + } + + } + + + public int getSequenceNum() { + return sequenceNum; + } + + + public GlobalOffset getCommitedoffset() { + return committedoffset; + } + + public GlobalINodeState getInodestate() { + return inodestate; + } + + /* public TransactionalFile(Adapter adapter, RandomAccessFile file) { + + this.adapter = adapter; + this.file = file; + decriptors = new Vector(); + } + + public void copyTransactionalFile(TransactionalFile tf){ + try { + int tmp = tf.commitedoffset.get(); + boolean flag = tf.to_be_created; + FileDescriptor fd = tf.file.getFD(); + Adapter ad = new Adapter(tf.adapter); + } catch (IOException ex) { + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } + }*/ + + /* public BlockDataStructure getBlockDataStructure(int blocknumber) { + synchronized (inodestate.lockmap) { + if (inodestate.lockmap.containsKey(blocknumber)) { + + return ((BlockDataStructure) (inodestate.lockmap.get(Long.valueOf(blocknumber)))); + } else { + + BlockDataStructure tmp = new BlockDataStructure(getInode(), blocknumber); + inodestate.lockmap.put(Integer.valueOf(blocknumber), tmp); + return tmp; + } + } + + }*/ + + + + public INode getInode() { + return inode; + } + /* public boolean deleteBlockLock(int blocknumber){ + synchronized(adapter.lockmap){ + //adapter.lockmap.get(blocknumber) + if (adapter.lockmap.containsKey(blocknumber)){ + if (((BlockLock)(adapter.lockmap.get(blocknumber))).referncount == 0){ + adapter.lockmap.remove(adapter.lockmap.get(blocknumber)); + return true; + } + else + return false; + } + else { + return false; + } + } + }*/ + public void close() { + try { + file.close(); + } catch (IOException ex) { + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public long getFilePointer(){ + + ExtendedTransaction me = Wrapper.getTransaction(); + TransactionLocalFileAttributes tmp = null; + + if (me == null) { + return non_Transactional_getFilePointer(); + } + + if (!(me.getGlobaltoLocalMappings().containsKey(this))){ + + //if (!(me.getFilesAccesses().containsKey(this.inode))) { + tmp = new TransactionLocalFileAttributes(0);/*, tf.getInodestate().commitedfilesize.get();*/ + + Vector dummy; + if (me.getAccessedFiles().containsKey(this.getInode())){ + dummy = (Vector) me.getAccessedFiles().get(this.getInode()); + } + else{ + dummy = new Vector(); + me.getAccessedFiles().put(this.getInode(), dummy); + } + + + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum()); + dummy.add(this); + me.getGlobaltoLocalMappings().put(this, tmp); + me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE); + + // me.addFile(this); + + //me.addFile(this); + } + + tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this); + if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS)){ + tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY); + //System.out.println("sad"); + //synchronized(this.committedoffset) + long target; + lockOffset(me); + //{ + + if (!(this.committedoffset.getOffsetReaders().contains(me))){ + this.committedoffset.getOffsetReaders().add(me); + /*synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + }*/ + } + + tmp.setLocaloffset(tmp.getLocaloffset() + this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset()); + target = this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset(); + + + offsetlock.unlock(); + //me.getHeldoffsetlocks().remove(offsetlock); + + Iterator it; + + if ((me.getWriteBuffer().get(inode)) != null) + { + + it = ((Vector) (me.getWriteBuffer().get(inode))).iterator(); + while (it.hasNext()){ + WriteOperations wrp = (WriteOperations) it.next(); + if (wrp.getBelongingto() == tmp && wrp.isUnknownoffset()) + wrp.setUnknownoffset(false); + /*wrp.getRange().setStart(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getStart()); + wrp.getRange().setEnd(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getEnd());*/ + wrp.getRange().setStart(target + wrp.getRange().getStart()); + wrp.getRange().setEnd(target + wrp.getRange().getEnd()); + } + } + + + //} + } + + + tmp.setUnknown_inital_offset_for_write(false); + + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Read the offset value for the file " + this.inode +" from descriptor " + this.sequenceNum + "\n"; + } + me.msg += Thread.currentThread().getName() + " Read the offset value for the file " + this.inode +" from descriptor " + this.sequenceNum + "\n";*/ + /* synchronized(benchmark.lock){ + System.out.println("offset " + Thread.currentThread() + " " + tmp.getLocaloffset()); + }*/ + return tmp.getLocaloffset(); + } + + public void seek(long offset) { + + if (appendmode) { + throw new PanicException("Cannot seek into a file opened in append mode"); + } + ExtendedTransaction me = Wrapper.getTransaction(); + + if (me == null) { + non_Transactional_Seek(offset); + return; + } + + else { + // if (me.getStatus() != Status.ACTIVE) + // throw new AbortedException(); + + TransactionLocalFileAttributes tmp = null; + //tf.offsetlock.lock(); + + //this.heldoffsetlocks.remove(tf.offsetlock); + //tf.offsetlock.unlock(); + if (!(me.getGlobaltoLocalMappings().containsKey(this))){ + //if (!(me.getFilesAccesses().containsKey(this.inode))) { + tmp = new TransactionLocalFileAttributes(offset);/*, tf.getInodestate().commitedfilesize.get();*/ + + Vector dummy; + if (me.getAccessedFiles().containsKey(this.getInode())){ + dummy = (Vector) me.getAccessedFiles().get(this.getInode()); + } + else{ + dummy = new Vector(); + me.getAccessedFiles().put(this.getInode(), dummy); + } + + + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum()); + dummy.add(this); + me.getGlobaltoLocalMappings().put(this, tmp); + me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE); + + //me.addFile(this); + } + tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this); + //tmp = ((TransactionLocalFileAttributes) (me.getFilesAccesses().get(this.getInode()))); + + if (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS) + tmp.setOffsetdependency(OffsetDependency.NO_DEPENDENCY); + + else if (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) + tmp.setOffsetdependency(OffsetDependency.WRITE_DEPENDENCY_2); + + tmp.setUnknown_inital_offset_for_write(false); + + tmp.setLocaloffset(offset); + + + /* synchronized(benchmark.lock){ + System.out.println(tmp.getLocaloffset()); + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Seeked to the file" + this.inode +" from descriptor " + this.sequenceNum + "\n"); + } + } + + public int read(byte[] b) { + + if (appendmode) { + throw new PanicException("Cannot seek into a file opened in append mode"); + } + + boolean firsttime = false; + ExtendedTransaction me = Wrapper.getTransaction(); + int size = b.length; + int result = 0; + + + + if (me == null) { // not a transaction, but any I/O operation even though within a non-transaction is considered a single opertion transactiion + return non_Transactional_Read(b); + } + + //if (me.getStatus() != Status.ACTIVE) + // throw new AbortedException(); + + + if (me.getGlobaltoLocalMappings().containsKey(this)){ + + /*long target; + Vector locktracker = new Vector(); + TreeMap hm = me.getSortedFileAccessMap(me.getAccessedFiles());; + Vector vec = (Vector)hm.get(inode); + Iterator vecit = vec.iterator(); + while(vecit.hasNext()){ + TransactionalFile tr = (TransactionalFile)vecit.next(); + TransactionLocalFileAttributes tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(tr); + + if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.offsetdependency == OffsetDependency.NO_ACCESS) || (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){ + tmp.setUnknown_inital_offset_for_write(false); + tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY); + tr.lockOffset(me); + System.out.printtln(Thread.currentThread() + " kiri"); + if (!(tr.committedoffset.getOffsetReaders().contains(me))){ + tr.committedoffset.getOffsetReaders().add(me); + target = this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset(); + me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + } + } + }*/ + + + + + TransactionLocalFileAttributes tmp = (TransactionLocalFileAttributes) me.getGlobaltoLocalMappings().get(this); + tmp.setUnknown_inital_offset_for_write(false); + if ((tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (tmp.offsetdependency == OffsetDependency.NO_ACCESS) || (tmp.getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){ + //System.out.println(Thread.currentThread() + " here"); + //synchronized(this.committedoffset){ + lockOffset(me); + if (tmp.getOffsetdependency() != OffsetDependency.WRITE_DEPENDENCY_2){ + tmp.setLocaloffset(tmp.getLocaloffset() + this.committedoffset.getOffsetnumber() - tmp.getCopylocaloffset()); + } + + tmp.setOffsetdependency(OffsetDependency.READ_DEPENDENCY); + if (!(this.committedoffset.getOffsetReaders().contains(me))){ + this.committedoffset.getOffsetReaders().add(me); + /* synchronized(benchmark.lock){ + System.out.println("adding offset " + committedoffset + " " +Thread.currentThread()); + }*/ + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + /*synchronized(benchmark.lock){ + System.out.println(Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ this.sequenceNum); + }*/ + } + + offsetlock.unlock(); + // me.getHeldoffsetlocks().remove(offsetlock); + //} + } + Iterator it; + if (me.getWriteBuffer().get(inode) != null) + //if (!(((Vector)(me.getWriteBuffer().get(inode))).isEmpty())) + { + it = ((Vector) (me.getWriteBuffer().get(inode))).iterator(); + while (it.hasNext()){ + + WriteOperations wrp = (WriteOperations) it.next(); + if (wrp.isUnknownoffset()){ + wrp.setUnknownoffset(false); + //synchronized(wrp.getOwnertransactionalFile().committedoffset){ + wrp.getOwnertransactionalFile().lockOffset(me); + + wrp.getRange().setStart(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getStart()); + wrp.getRange().setEnd(wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset() + wrp.getRange().getEnd()); + if ((wrp.getBelongingto().getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_1) || (wrp.getBelongingto().offsetdependency == OffsetDependency.NO_ACCESS) || (wrp.getBelongingto().getOffsetdependency() == OffsetDependency.WRITE_DEPENDENCY_2)){ + wrp.getBelongingto().setOffsetdependency(OffsetDependency.READ_DEPENDENCY); + wrp.getBelongingto().setUnknown_inital_offset_for_write(false); + if (!(wrp.getOwnertransactionalFile().committedoffset.getOffsetReaders().contains(me))) + wrp.getOwnertransactionalFile().committedoffset.getOffsetReaders().add(me); + wrp.getBelongingto().setLocaloffset(wrp.getBelongingto().getLocaloffset() + wrp.getOwnertransactionalFile().committedoffset.getOffsetnumber() - wrp.getBelongingto().getCopylocaloffset()); + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ wrp.getOwnertransactionalFile().sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Offset Readers for file " + this.inode + " from descriptor "+ wrp.getOwnertransactionalFile().sequenceNum +"\n"); + } + + // me.getHeldoffsetlocks().remove(wrp.getOwnertransactionalFile().offsetlock); + wrp.getOwnertransactionalFile().offsetlock.unlock(); + + //} + + + + markAccessedBlocks(me, (int)wrp.getRange().getStart(), (int)(wrp.getRange().getEnd() - wrp.getRange().getStart()), BlockAccessModesEnum.WRITE); +// markWriteBlocks((int)wrp.getRange().getStart(), (int)(wrp.getRange().getEnd() - wrp.getRange().getStart())); + } + } + } + + /* if (!(me.isWritesmerged())){ + // synchronized(benchmark.lock){ + // System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer()); + // } + mergeWrittenData(); + }*/ + // System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer()); + if ((Boolean)me.merge_for_writes_done.get(inode) == Boolean.FALSE){ + // synchronized(benchmark.lock){ + System.out.println("ssssad " + Thread.currentThread() + " " + me.getWriteBuffer()); + mergeWrittenData(me); + //} + } + + + long loffset = tmp.getLocaloffset(); + markAccessedBlocks(me, loffset, size, BlockAccessModesEnum.READ); + + + Vector writebuffer; + if ((me.getWriteBuffer().get(this.inode)) != null) + writebuffer = (Vector) (me.getWriteBuffer().get(this.inode)); + else { + writebuffer = new Vector(); + me.getWriteBuffer().put(this.inode, writebuffer); + } + Range readrange = new Range(loffset, loffset + size); + Range writerange = null; + Range[] intersectedrange = new Range[writebuffer.size()]; + WriteOperations[] markedwriteop = new WriteOperations[writebuffer.size()]; + + int counter = 0; + + + + + boolean flag = false; + //System.out.println("yani che>??"); + + it = writebuffer.iterator(); + while (it.hasNext()) { + + WriteOperations wrp = (WriteOperations) it.next(); + writerange = wrp.getRange(); + if (writerange.includes(readrange)) { + markedwriteop[counter] = wrp; + flag = true; + break; + } + + if (writerange.hasIntersection(readrange)) { + intersectedrange[counter] = readrange.intersection(writerange); + markedwriteop[counter] = wrp; + + counter++; + } + } + + + // for block versioning mechanism + /*if (!(validateBlocksVersions(startblock, targetblock))) { ////check to see if version are still valid + + throw new AbortedException(); + + }*/ + if (flag) { + + result = readFromBuffer(b, tmp, markedwriteop[counter],writerange); + + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Read " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Read " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + return result; + } + + else{ + + if (counter == 0) { + /* synchronized(benchmark.lock){ + System.out.println("here" +Thread.currentThread()); + }*/ + + // lockOffset(me); + result = readFromFile(me, b, tmp); + } + else { + + for (int i = 0; i < counter; i++) { + + + Byte[] data = markedwriteop[i].getData(); + byte[] copydata = new byte[data.length]; + + for (int j = 0; j < data.length; j++) { + copydata[j] = data[j].byteValue(); + } + System.arraycopy(copydata, (int) (intersectedrange[i].getStart() - markedwriteop[i].getRange().getStart()), b, (int) (intersectedrange[i].getStart() - readrange.getStart()), (int) (Math.min(intersectedrange[i].getEnd(), readrange.getEnd()) - intersectedrange[i].getStart())); + result += Math.min(intersectedrange[i].getEnd(), readrange.getEnd()) - intersectedrange[i].getStart(); + } + + Range[] non_intersected_ranges = readrange.minus(intersectedrange, counter); + Vector occupiedblocks = new Vector(); + Vector heldlocks = new Vector(); + for (int i = 0; i < non_intersected_ranges.length; i++) { + int st = FileBlockManager.getCurrentFragmentIndexofTheFile(non_intersected_ranges[i].getStart()); + int en = FileBlockManager.getCurrentFragmentIndexofTheFile(non_intersected_ranges[i].getEnd()); + for (int j = st; j <= en; j++) { + if (!(occupiedblocks.contains(Integer.valueOf(j)))) { + occupiedblocks.add(Integer.valueOf(j)); + } + } + } + + + + lockOffset(me); + me.getHeldoffsetlocks().add(offsetlock); + + + for (int k = 0; k < occupiedblocks.size(); k++) { // locking the block locks + + while (me.getStatus() == Status.ACTIVE) { + + BlockDataStructure block = this.inodestate.getBlockDataStructure((Integer)(occupiedblocks.get(k)));//(BlockDataStructure) tmp.adapter.lockmap.get(Integer.valueOf(k))); + + //synchronized(block){ + + // if (block.getLock().readLock().tryLock()) { + block.getLock().readLock().lock(); + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Locked The Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added The Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + //synchronized (block){ + if (!(block.getReaders().contains(me))){ + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Added to Block Readers for Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Added to Block Readers for Block Number " + block.getBlocknumber()+ " for file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + block.getReaders().add(me); + } + me.getHeldblocklocks().add(block.getLock().readLock()); + //heldlocks.add(block.getLock().readLock()); + //} + break; + // } + //} else { + // me.getContentionmanager().resolveConflict(me, block); + // } + //} + } + if (me.getStatus() == Status.ABORTED) { + //unlockLocks(heldlocks); + //offsetlock.unlock(); + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Aborted in locking blocks in read\n"); + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Aborted \n"; + }*/ + // Thread.currentThread().stop(); + throw new AbortedException(); + } + } + /* + int expvalue = ((Integer) tmp.getBlockversions().get(Integer.valueOf(k))).intValue(); + while (me.getStatus() == Status.ACTIVE) { + BlockDataStructure block = ((BlockDataStructure) tmp.adapter.lockmap.get(Integer.valueOf(k))); + if (block.getLock().tryLock()) { + heldlocks.add(block.getLock()); + if (!(block.getVersion().get() == expvalue)) { // for block versioning mechanism + me.abort(); + } + else { + break; + } + } + else { + me.getContentionManager().resolveConflict(me, block.getOwner()); + } + } + if (me.getStatus() == Status.ABORTED) { + unlockLocks(heldlocks); + offsetlock.unlock(); + throw new AbortedException(); + } + } + }*/ + + + for (int i = 0; i < non_intersected_ranges.length; i++) { + try { + synchronized(benchmark.lock){ + System.out.println("read start " + non_intersected_ranges[i].getStart()); + } + file.seek(non_intersected_ranges[i].getStart()); + int tmpsize = file.read(b, (int) (non_intersected_ranges[i].getStart() - readrange.getStart()), (int) (non_intersected_ranges[i].getEnd() - non_intersected_ranges[i].getStart())); + result += tmpsize; + } catch (IOException ex) { + + //unlockLocks(heldlocks); + //offsetlock.unlock(); + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } + } + me.unlockAllLocks(); + tmp.setLocaloffset(tmp.getLocaloffset() + result); + // unlockLocks(heldlocks); + // offsetlock.unlock(); + } + /*synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Read from file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Read from file " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + return result; + } + + } else { // add to the readers list + System.out.println("form read???"); + me.addFile(this); + return read(b); + } + + } + + public void write(byte[] data) throws IOException { + + if (!(writemode)) { + throw new IOException(); + + } + + ExtendedTransaction me = Wrapper.getTransaction(); + int size = data.length; + + + if (me == null) // not a transaction + { + + non_Transactional_Write(data); + return; + } + + //else if (me.getFilesAccesses().containsKey(this.getInode())) // + //{ + // if (me.getStatus() != Status.ACTIVE) + // throw new AbortedException(); + + if (me.getGlobaltoLocalMappings().containsKey(this)) // + { + + + Byte[] by = new Byte[size]; + for (int i = 0; i < size; i++) { + by[i] = Byte.valueOf(data[i]); + } + TransactionLocalFileAttributes tmp = ((TransactionLocalFileAttributes) (me.getGlobaltoLocalMappings().get(this))); + + /*if (appendmode) { + newwriterange = new Range((((Range) (tm.firstKey())).getStart()), (((Range) (tm.firstKey())).getEnd()) + size); + Range range = new Range((((Range) (tm.firstKey())).getStart()), (((Range) (tm.firstKey())).getEnd())); + Byte[] appenddata = new Byte[(int) (newwriterange.getEnd() - newwriterange.getStart())]; + Byte[] tempor = new Byte[(int) (range.getEnd() - range.getStart())]; + System.arraycopy(tempor, 0, appenddata, 0, tempor.length); + System.arraycopy(by, 0, appenddata, tempor.length, by.length); + tm.remove(range); + tm.put(newwriterange, appenddata); + tmp.setLocaloffset(loffset + size); + tmp.setFilelength(tmp.getFilelength() + size); + + return; + }*/ + Vector dummy; + if (((Vector)(me.getWriteBuffer().get(this.inode))) != null){ + dummy = new Vector((Vector)(me.getWriteBuffer().get(this.inode))); + } + else + dummy = new Vector(); + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " gg " + tmp.getLocaloffset() + " " + (tmp.getLocaloffset()+by.length)); + }*/ + /*if (!(tmp.isUnknown_inital_offset_for_write())){ + lockOffset(me); + tmp.setLocaloffset(this.committedoffset.getOffsetnumber()); + offsetlock.unlock(); + }*/ + + dummy.add(new WriteOperations(by, new Range(tmp.getLocaloffset(), tmp.getLocaloffset() + by.length), tmp.isUnknown_inital_offset_for_write(), this, tmp)); + me.getWriteBuffer().put(this.inode, dummy); + + long loffset = tmp.getLocaloffset(); + + + tmp.setLocaloffset(tmp.getLocaloffset() + by.length); + + me.merge_for_writes_done.put(inode, Boolean.FALSE); + //me.setWritesmerged(false); + + + + if (!(tmp.isUnknown_inital_offset_for_write())){ + markAccessedBlocks(me, loffset, size, BlockAccessModesEnum.WRITE); +// markWriteBlocks(loffset, size); + } + /*{ + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size); + for (int i = startblock; i <= targetblock; i++) { + if (me.getAccessedBlocks().containsKey(Integer.valueOf(i))) { + if (((BlockAccessModesEnum) (me.getAccessedBlocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) { + me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE); + } + } else { + me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE); + // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism + } + } + }*/ + + if (tmp.getOffsetdependency() == OffsetDependency.NO_ACCESS) + tmp.offsetdependency = OffsetDependency.WRITE_DEPENDENCY_1; + + + + /*if ((tmp.access_from_absolute_offset) || !(tmp.relocatablewrite)) + { + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size); + for (int i = startblock; i <= targetblock; i++) { + if (tmp.getAccesedblocks().containsKey(Integer.valueOf(i))) { + if (((BlockAccessModesEnum) (tmp.getAccesedblocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) { + tmp.getAccesedblocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE); + } + } else { + tmp.getAccesedblocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE); + // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism + } + } + } + + if (tmp.access_from_absolute_offset){ + + mergeWrittenData(tmp.getNon_Speculative_Writtendata(), data, newwriterange); + tmp.setLocaloffset(loffset + size); + if (tmp.getLocaloffset() > tmp.getFilelength()) { + tmp.setFilelength(tmp.getLocaloffset()); + } + return; + } + + else // for comtimious determingin the accessed block is postpond till commit instant + { + Byte[] dd = new Byte[size]; + System.arraycopy(by, 0, dd, 0, size); + if (!(tmp.getSpeculative_Writtendata().isEmpty())){ + + Range lastrange = (Range) tmp.getSpeculative_Writtendata().lastKey(); + if (lastrange.getEnd() == newwriterange.getStart()){ + dd = new Byte[(int)(size + lastrange.getEnd() - lastrange.getStart())]; + System.arraycopy(((Byte[])tmp.getSpeculative_Writtendata().get(lastrange)), 0, dd, 0, (int)(lastrange.getEnd() - lastrange.getStart())); + System.arraycopy(by, 0, dd, (int)(lastrange.getEnd() - lastrange.getStart()), size); + newwriterange = new Range(lastrange.getStart(), size + lastrange.getEnd()); + tmp.getSpeculative_Writtendata().remove(lastrange); + } + + } + + tmp.getSpeculative_Writtendata().put(newwriterange, dd); + + tmp.setLocaloffset(loffset + size); + if (tmp.getLocaloffset() > tmp.getFilelength()) { + tmp.setFilelength(tmp.getLocaloffset()); + } + + return; + } + + */ + + /* + + if (tmp.accessmode == TransactionLocalFileAttributes.MODE.READ) + tmp.accessmode = TransactionLocalFileAttributes.MODE.READ_WRITE; + else if (tmp.accessmode == TransactionLocalFileAttributes.MODE.WRITE) + simpleWritetoBuffer(by, newwriterange, tm); + */ + // me.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Writes to " + this.inode + " from descriptor "+ this.sequenceNum +"\n"); + + } else { + // System.out.println("form write??"); + // me.addFile(this/*, TransactionLocalFileAttributes.MODE.WRITE*/); + //if (!(me.getGlobaltoLocalMappings().containsKey(this))){ + //if (!(me.getFilesAccesses().containsKey(this.inode))) { + TransactionLocalFileAttributes tmp = new TransactionLocalFileAttributes(0);/*, tf.getInodestate().commitedfilesize.get();*/ + + Vector dummy; + if (me.getAccessedFiles().containsKey(this.getInode())){ + dummy = (Vector) me.getAccessedFiles().get(this.getInode()); + } + else{ + dummy = new Vector(); + me.getAccessedFiles().put(this.getInode(), dummy); + } + + + + // this.msg.put(System.nanoTime(), Thread.currentThread().getName() + " Unlocked the offset lock " + tf.offsetlock + " for file " + tf.getInode() + " form descriptor " + tf.getSequenceNum()); + dummy.add(this); + me.getGlobaltoLocalMappings().put(this, tmp); + me.merge_for_writes_done.put(this.getInode(), Boolean.TRUE); + + //me.addFile(this); + //} + + write(data); + } + /* synchronized(benchmark.lock){ + benchmark.msg += Thread.currentThread().getName() + " Writes to " + this.inode + " from descriptor "+ this.sequenceNum +"\n"; + }*/ + + + } + + + private void markAccessedBlocks(ExtendedTransaction me,long loffset, int size, BlockAccessModesEnum mode){ + + TreeMap map; + + if (me.getAccessedBlocks().get(this.getInode()) != null) + map = (TreeMap) me.getAccessedBlocks().get(this.getInode()); + else{ + map = new TreeMap(); + me.getAccessedBlocks().put(this.inode, map); + } + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size); + for (int i = startblock; i <= targetblock; i++) { + if (map.containsKey(Integer.valueOf(i))){ + if (map.get(Integer.valueOf(i)) != mode){ + map.put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE); + } + } + else{ + map.put(Integer.valueOf(i), mode); + } + } + /*int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size); + for (int i = startblock; i <= targetblock; i++) { + if (me.getAccessedBlocks().containsKey(Integer.valueOf(i))) { + if (((BlockAccessModesEnum) (me.getAccessedBlocks().get(Integer.valueOf(i)))) == BlockAccessModesEnum.READ) { + me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.READ_WRITE); + } + + + } else { + me.getAccessedBlocks().put(Integer.valueOf(i), BlockAccessModesEnum.WRITE); + // tmp.getBlockversions().put(Integer.valueOf(i), Integer.valueOf(getBlockDataStructure(i).getVersion().get())); //For Block Versioning Mechanism + } + }*/ + } + +/* private void markWriteBlocks(long loffset, int size){ + ExtendedTransaction me = CustomThread.getTransaction(); + SortedSet tt; + if (me.writeBlocks.get(this.inode) != null) + tt = (SortedSet) me.writeBlocks.get(this.inode); + else { + tt = new TreeSet(); + me.writeBlocks.put(this.inode, tt); + } + + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(loffset); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(loffset, size); + for (int i = startblock; i <= targetblock; i++) { + tt.add(Integer.valueOf(i)); + } + }*/ + + private int readFromFile(ExtendedTransaction me, byte[] readdata, TransactionLocalFileAttributes tmp) { + + + //ExtendedTransaction me = Wrapper.getTransaction(); + int st = FileBlockManager.getCurrentFragmentIndexofTheFile(tmp.getLocaloffset()); + int end = FileBlockManager.getTargetFragmentIndexofTheFile(tmp.getLocaloffset(), readdata.length); + + BlockDataStructure block = null; + boolean locked = false; + for (int k = st; k <= end; k++) { + // int expvalue = ((Integer) tmp.getBlockversions().get(Integer.valueOf(k))).intValue(); // all comments here for versioning mechanism + while (me.getStatus() == Status.ACTIVE) { + //BlockDataStructure block = ((BlockDataStructure) this.inodestate.lockmap.get(Integer.valueOf(k))); + // BlockDataStructure block; + //if (me.getAccessedBlocks().get(inode)) + block = this.inodestate.getBlockDataStructure(Integer.valueOf(k)); + + block.getLock().readLock().lock(); + // me.getHeldblocklocks().add(block.getLock().readLock()); + if (!(block.getReaders().contains(me))){ + block.getReaders().add(me); + } + locked = true; + // if (!(block.getVersion().get() == expvalue)) { + // me.abort(); + // } else { + break; + // } + // } + /* else { + me.getContentionmanager().resolveConflict(me, block); + }*/ + + } + if (me.getStatus() == Status.ABORTED) { + int m; + if (locked){ + m = k+1; + } + else + m = k; + for (int i=st; i= wrp.getRange().getEnd()) { + + suffixdata = new Byte[(int) (wrp2.getRange().getEnd() - intersectedrange.getEnd())]; + suffixdata = (Byte[]) (wrp2.getData()); + startsuffix = intersectedrange.getEnd() - wrp2.getRange().getStart(); + suffixsize = (int)(wrp2.getRange().getEnd() - intersectedrange.getEnd()); + suffix = true; + //System.out.println("wrp2 > wrp"); + + endsuffix = wrp2.getRange().getEnd(); + //suffixstart = (int) (intersectedrange[i].getEnd() - intersectedrange[i].getStart()); + } + + else if (wrp.getRange().getEnd() > wrp2.getRange().getEnd()) { + suffixdata = new Byte[(int) (wrp.getRange().getEnd() - intersectedrange.getEnd())]; + suffixdata = (Byte[]) (wrp.getData()); + startsuffix = intersectedrange.getEnd() - wrp.getRange().getStart(); + suffixsize = (int)(wrp.getRange().getEnd() - intersectedrange.getEnd()); + // System.out.println("wrp2 < wrp"); + endsuffix = wrp.getRange().getEnd(); + suffix = true; + + } + /* System.out.println("prefix start:" + startprefix); + System.out.println("suffix end:" + endsuffix); + System.out.println("suffix start:" + startsuffix); + System.out.println("intermediate start:" + intermediatetart); + + System.out.println("suffix size:" + suffixsize);*/ + + + Byte[] data_to_insert; + + if ((prefix) && (suffix)) { + data_to_insert = new Byte[(int) (endsuffix - startprefix)]; + System.arraycopy(prefixdata, 0, data_to_insert, 0, prefixsize); + System.arraycopy(wrp2.getData(), (int)(intersectedrange.getStart() - wrp2.getRange().getStart()), data_to_insert, prefixsize, intermediatesize); + System.arraycopy(suffixdata, (int)startsuffix, data_to_insert, (prefixsize + intermediatesize), suffixsize); + wrp.setData(data_to_insert); + wrp.setRange(new Range(startprefix, endsuffix)); + } + + } + } + } + Iterator it = toberemoved.iterator(); + while (it.hasNext()) + vec.remove(it.next()); + + toberemoved.clear(); + Collections.sort(vec); + me.merge_for_writes_done.put(inode, Boolean.TRUE); + //me.setWritesmerged(true); + + /*} else if (prefix) { + data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size)]; + System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start)); + System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size); + to_be_merged_data_range.setStart(start); + } else if (suffix) { + data_to_insert = new Byte[(int) (to_be_merged_data_range.getEnd() - end + size)]; + System.arraycopy(by, 0, data_to_insert, 0, size); + System.arraycopy(suffixdata, suffixstart, data_to_insert, size, (int) (end - to_be_merged_data_range.getEnd())); + to_be_merged_data_range.setEnd(end); + } else { + data_to_insert = new Byte[size]; + System.arraycopy(data_to_insert, (int) (to_be_merged_data_range.getStart() - start), by, 0, size); + }*/ + //target.put(to_be_merged_data_range, data_to_insert); + +/* + if (flag) { + int datasize = (int) (oldwriterange.getEnd() - oldwriterange.getStart()); + Byte[] original = (Byte[]) (wrp.getData()); + byte[] originaldata = new byte[datasize]; + + //for (int i = 0; i < data.length; i++) { + // originaldata[i] = original[i].byteValue(); + // } + System.arraycopy(data, 0, originaldata, (int) (to_be_merged_data_range.getStart() - oldwriterange.getStart()), size); + Byte[] to_be_inserted = new Byte[datasize]; + + for (int i = 0; i < datasize; i++) { + to_be_inserted[i] = Byte.valueOf(originaldata[i]); + } + target.put(oldwriterange, to_be_inserted); + return; + + } else if (counter == 0) { + target.put(to_be_merged_data_range, data); + return; + + } else { + + int suffixstart = 0; + long start = 0; + long end = 0; + Byte[] prefixdata = null; + Byte[] suffixdata = null; + boolean prefix = false; + boolean suffix = false; + + for (int i = 0; i < counter; i++) { + if (markedwriteranges[i].getStart() < to_be_merged_data_range.getStart()) { + prefixdata = new Byte[(int) (to_be_merged_data_range.getStart() - markedwriteranges[i].getStart())]; + prefixdata = (Byte[]) (target.get(markedwriteranges[i])); + start = markedwriteranges[i].getStart(); + //newdata = new Byte[size + newwriterange.getStart() - markedwriteranges[i].getStart()]; + //System.arraycopy(by, 0, newdata, newwriterange.getStart() - markedwriteranges[i].getStart(), size); + //System.arraycopy(originaldata, 0, newdata, 0, newwriterange.getStart() - markedwriteranges[i].getStart()); + + //newwriterange.setStart(markedwriteranges[i].getStart()); + prefix = true; + + + } else if (markedwriteranges[i].getEnd() > to_be_merged_data_range.getEnd()) { + + suffixdata = new Byte[(int) (markedwriteranges[i].getStart() - to_be_merged_data_range.getStart())]; + suffixdata = (Byte[]) (target.get(markedwriteranges[i])); + end = markedwriteranges[i].getEnd(); + + //Byte [] originaldata = (Byte [])(tmp.getWrittendata().get(markedwriteranges[i])); + //newdata = new Byte[size + newwriterange.getStart() - markedwriteranges[i].getStart()]; + //System.arraycopy(originaldata, 0, newdata, 0, newwriterange.getStart() - markedwriteranges[i].getStart()); + + //newwriterange.setStart(markedwriteranges[i].getStart()); + ///newwriterange.setEnd(markedwriteranges[i].getEnd()); + suffix = true; + suffixstart = (int) (intersectedrange[i].getEnd() - intersectedrange[i].getStart()); + //tm.remove(markedwriteranges[i]); + } + target.remove(markedwriteranges[i]); + + } + Byte[] data_to_insert; + + if ((prefix) && (suffix)) { + data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size - to_be_merged_data_range.getEnd() + end)]; + System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start)); + System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size); + System.arraycopy(suffixdata, suffixstart, data_to_insert, (int) (size + to_be_merged_data_range.getStart() - start), (int) (end - to_be_merged_data_range.getEnd())); + to_be_merged_data_range.setStart(start); + to_be_merged_data_range.setEnd(end); + } else if (prefix) { + data_to_insert = new Byte[(int) (to_be_merged_data_range.getStart() - start + size)]; + System.arraycopy(prefixdata, 0, data_to_insert, 0, (int) (to_be_merged_data_range.getStart() - start)); + System.arraycopy(by, 0, data_to_insert, (int) (to_be_merged_data_range.getStart() - start), size); + to_be_merged_data_range.setStart(start); + } else if (suffix) { + data_to_insert = new Byte[(int) (to_be_merged_data_range.getEnd() - end + size)]; + System.arraycopy(by, 0, data_to_insert, 0, size); + System.arraycopy(suffixdata, suffixstart, data_to_insert, size, (int) (end - to_be_merged_data_range.getEnd())); + to_be_merged_data_range.setEnd(end); + } else { + data_to_insert = new Byte[size]; + System.arraycopy(data_to_insert, (int) (to_be_merged_data_range.getStart() - start), by, 0, size); + } + target.put(to_be_merged_data_range, data_to_insert); + return; + }*/ + + } + + public void non_Transactional_Write(byte[] data){ + + Vector heldlocks = new Vector(); + boolean flag = true; + offsetlock.lock(); + int startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(committedoffset.getOffsetnumber()); + int targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(committedoffset.getOffsetnumber(), data.length); + for (int i = startblock; i <= targetblock; i++) { + BlockDataStructure block =this.inodestate.getBlockDataStructure(i); + //if (block.getLock().writeLock().tryLock()) { + block.getLock().writeLock().lock(); + heldlocks.add(block.getLock().writeLock()); + //} else { + // unlockLocks(heldlocks); + // offsetlock.unlock(); + // flag = false; + // break; + //} + } + + /*if (flag) { + throw new PanicException("The I/O operation could not be done to contention for the file"); + }*/ + + //else { + try { + + file.seek(committedoffset.getOffsetnumber()); + file.write(data); + + committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +data.length); + + } catch (IOException ex) { + Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + } finally { + unlockLocks(heldlocks); + offsetlock.unlock(); + } + //} + } + + public int non_Transactional_Read(byte[] b){ + int size = -1; + Vector heldlocks = new Vector(); + boolean flag = true; + offsetlock.lock(); + int startblock; + int targetblock; + startblock = FileBlockManager.getCurrentFragmentIndexofTheFile(committedoffset.getOffsetnumber()); + targetblock = FileBlockManager.getTargetFragmentIndexofTheFile(committedoffset.getOffsetnumber(), size); + /* long offset = committedoffset.getOffsetnumber(); + committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +b.length); + if (!(committedoffset.getOffsetReaders().isEmpty())){ + Iterator it2 = committedoffset.getOffsetReaders().iterator(); // for visible readers strategy + while ( it2.hasNext()) + { + ExtendedTransaction tr = (ExtendedTransaction) it2.next(); + tr.abort(); + } + committedoffset.getOffsetReaders().clear(); + } + offsetlock.unlock();*/ + + for (int i = startblock; i <= targetblock; i++) { + BlockDataStructure block = this.inodestate.getBlockDataStructure(i); + //if (block.getLock().readLock().tryLock()) { + block.getLock().readLock().lock(); + heldlocks.add(block.getLock().readLock()); + /*} else { + unlockLocks(heldlocks); + offsetlock.unlock(); + flag = false; + break; + }*/ + } + /*if (flag) { + size = -1; + } else {*/ + + + + // try { + //ByteBuffer buffer = ByteBuffer.wrap(b); + //System.out.println(committedoffset.getOffsetnumber()); + //size = file.getChannel().read(buffer, offset); + //file.seek(committedoffset.getOffsetnumber()); + // size = file.read(b); + size = invokeNativepread(b, committedoffset.getOffsetnumber(), b.length); + + + committedoffset.setOffsetnumber(committedoffset.getOffsetnumber() +size); + if (!(committedoffset.getOffsetReaders().isEmpty())){ + Iterator it2 = committedoffset.getOffsetReaders().iterator(); // for visible readers strategy + while ( it2.hasNext()) + { + ExtendedTransaction tr = (ExtendedTransaction) it2.next(); + tr.abort(); + } + committedoffset.getOffsetReaders().clear(); + } + + // } catch (IOException ex) { + // Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + // size = -1; + // } finally { + unlockLocks(heldlocks); + offsetlock.unlock(); + if (size == 0) + size = -1; + // } + // } + return size; + + } + + public void non_Transactional_Seek(long offset){ + offsetlock.lock(); + //try { + //file.seek(offset); + //synchronized(adapter){ + committedoffset.setOffsetnumber(offset); + // inodestate.commitedfilesize.set(offset); + //} + //} catch (IOException ex) { + /// Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + //} finally { + offsetlock.unlock(); + //} + } + + public long non_Transactional_getFilePointer(){ + long offset = -1;; + offsetlock.lock(); + + + // try { + + //synchronized(adapter){ + offset = committedoffset.getOffsetnumber(); + //} + // } catch (IOException ex) { + // Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex); + // } finally { + offsetlock.unlock(); + // } + return offset; + } + + public int compareTo(Object arg0) { + TransactionalFile tf = (TransactionalFile) arg0; + if (this.inode.getNumber() < tf.inode.getNumber()) + return -1; + else if (this.inode.getNumber() > tf.inode.getNumber()) + return 1; + else { + if (this.sequenceNum < tf.sequenceNum) + return -1; + else + return 1; + } + } + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFileWrapperFactory.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFileWrapperFactory.java new file mode 100644 index 00000000..b684a556 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFileWrapperFactory.java @@ -0,0 +1,67 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package TransactionalIO.core; + +import java.io.File; +import java.util.HashMap; + +/** + * + * @author navid + */ +public class TransactionalFileWrapperFactory { + + + + private TransactionalFileWrapperFactory() { + } + // private static HashMap filemappings; + public static HashMap filemappings = new HashMap(); + + private static native long getINodeNative(String filename); + + static{ + //System.load("/home/navid/libnav.so"); + System.load("/home/navid/libnativeIO.so"); + } + + static INode getINodefromFileName(String filename) { + return new INode(getINodeNative(filename), filename); + } + + + + public synchronized static GlobalINodeState getTateransactionalFileINodeState(INode inode) { + + return (GlobalINodeState)filemappings.get(inode.getNumber()); + + } + public synchronized static GlobalINodeState createTransactionalFile(INode inode, String filename, String mode) { + + long inodenumber = inode.getNumber(); + if (inodenumber != -1) + + if (filemappings.containsKey(inode.getNumber())) { + // System.out.println("here"); + return (GlobalINodeState)filemappings.get(inode.getNumber()); + + } else { + + + long length = new File(filename).length(); + + GlobalINodeState inodestate = new GlobalINodeState(inode, length); + filemappings.put(inode.getNumber(), inodestate); + return inodestate; + } + + else + { + return null; + } + + } + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Wrapper.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Wrapper.java new file mode 100644 index 00000000..b68f488e --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/Wrapper.java @@ -0,0 +1,115 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +import TransactionalIO.core.ExtendedTransaction; + +import TransactionalIO.core.CustomThread; +import TransactionalIO.interfaces.TransactionStatu; +import java.util.Vector; + + +/** + * + * @author navid + */ +public class Wrapper{ + + + private ExtendedTransaction transaction = new ExtendedTransaction(); + private static ThreadLocal IOtransactioncontainer = new ThreadLocal(); + private static ThreadLocal onMemoryAbort = new ThreadLocal(); + private static ThreadLocal onIOAbort = new ThreadLocal(); + + + + public static void prepareIOCommit(){ + + getTransaction().prepareCommit(); + } + + public static void commitIO(){ + getTransaction().commitChanges(); + } + + + + public static void Initialize(TransactionStatu memory){ + ExtendedTransaction transaction = new ExtendedTransaction(); + setTransaction(transaction); + transaction.setOtherSystem(memory); + + if (memory != null) + memory.setOtherSystem(transaction); + + + + /* setonIOAbort(new Vector()); + setonMemoryAbort(new Vector()); + + getonIOAbort().add(new terminateHandler() { + public void cleanup() { + Thread.getTransaction().abort(); + synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" KEWL"); + } + } + }); + + getonMemoryAbort().add(new terminateHandler() { + public void cleanup() { + CustomThread.getTransaction().abort(); + synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" KEWL"); + } + } + });*/ + } + + public static void memoryCommit(){ + + } + + + public static void setTransaction(ExtendedTransaction transaction){ + IOtransactioncontainer.set(transaction); + } + + + + public static ExtendedTransaction getTransaction(){ + return (ExtendedTransaction) IOtransactioncontainer.get(); + } + + public static void setonIOAbort(Vector vec){ + onIOAbort.set(vec); + } + + + private static Vector getonIOAbort(){ + return (Vector) onIOAbort.get(); + } + + public static void setonMemoryAbort(Vector vec){ + onMemoryAbort.set(vec); + } + + + private static Vector getonMemoryAbort(){ + return (Vector) onMemoryAbort.get(); + } + + + + + + + + +} + + + diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/WriteOperations.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/WriteOperations.java new file mode 100644 index 00000000..9a376675 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/core/WriteOperations.java @@ -0,0 +1,82 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.core; + +import TransactionalIO.Utilities.Range; + +/** + * + * @author navid + */ +public class WriteOperations implements Comparable{ + + private Byte[] data; + private Range range; + private boolean unknownoffset; + private TransactionLocalFileAttributes belongingto; + private TransactionalFile ownertransactionalfile; + + public WriteOperations(Byte[] data, Range range, boolean unknownoffset, TransactionalFile ownertransactionalfile, TransactionLocalFileAttributes belongingto) { + this.data = data; + this.range = range; + this.unknownoffset = unknownoffset; + this.ownertransactionalfile = ownertransactionalfile; + this.belongingto = belongingto; + } + + public TransactionalFile getOwnertransactionalFile() { + return ownertransactionalfile; + } + + public void setOwnertransaction(TransactionalFile ownertransaction) { + this.ownertransactionalfile = ownertransaction; + } + + + + public Byte[] getData() { + return data; + } + + public Range getRange() { + return range; + } + + public boolean isUnknownoffset() { + return unknownoffset; + } + + public void setData(Byte[] data) { + this.data = new Byte[data.length]; + System.arraycopy(data, 0, this.data, 0, data.length); + } + + public void setRange(Range range) { + this.range = range; + } + + public void setUnknownoffset(boolean unknownoffset) { + this.unknownoffset = unknownoffset; + } + + public TransactionLocalFileAttributes getBelongingto() { + return belongingto; + } + + public void setBelongingto(TransactionLocalFileAttributes belongingto) { + this.belongingto = belongingto; + } + + + public int compareTo(Object other) { + WriteOperations tmp = (WriteOperations) other; + return this.range.compareTo(tmp.range); + } + + + + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/AbortedException.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/AbortedException.java new file mode 100644 index 00000000..b10eb17c --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/AbortedException.java @@ -0,0 +1,56 @@ +/* + * AbortedException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package TransactionalIO.exceptions; +/** + * Thrown by an attempt to open a TMObject to indicate + * that the current transaction cannot commit. + **/ +public class AbortedException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new DeniedException instance with no detail message. + */ + public AbortedException() { + super(); + } + + + /** + * Creates a new Denied instance with the specified detail message. + * @param msg the detail message. + */ + public AbortedException(String msg) { + super(msg); + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/GracefulException.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/GracefulException.java new file mode 100644 index 00000000..73ccf1cf --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/GracefulException.java @@ -0,0 +1,48 @@ +/* + * GracefulException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package TransactionalIO.exceptions; + +/** + * Thrown by the BaseContentionManager when the benchmark time has elapsed. + **/ +public class GracefulException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new GracefulException instance with no detail message. + */ + public GracefulException() { + super(); + } + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/PanicException.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/PanicException.java new file mode 100644 index 00000000..ed58fc60 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/PanicException.java @@ -0,0 +1,69 @@ +/* + * PanicException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package TransactionalIO.exceptions; + +/** + * Thrown to indicate an error in the use of the transactional memory; + * that is, a violation of the assumptions of use. + */ +public class PanicException extends java.lang.RuntimeException { + + /** + * Creates new PanicException with no detail message. + */ + public PanicException() { + } + + public PanicException(String format, Object ... args) { + super(String.format(format, args)); + } + + /** + * Creates a new PanicException with the specified detail message. + * + * @param msg the detail message. + */ + public PanicException(String msg) { + super(msg); + } + + /** + * Creates an PanicException with the specified cause. + * + * @param cause Throwable that caused PanicException to be thrown + */ + public PanicException(Throwable cause) { + super(cause); + } +} + diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/SnapshotException.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/SnapshotException.java new file mode 100644 index 00000000..b15c126e --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/exceptions/SnapshotException.java @@ -0,0 +1,58 @@ +/* + * SnapshotException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package TransactionalIO.exceptions; + +/** + * Thrown if shapshot validation fails. Will abort transaction if not + * caught by the application. + * + * @author Maurice Herlihy + */ +public class SnapshotException extends java.lang.RuntimeException { + + /** + * Creates a new SnapshotException instance with no detail message. + */ + public SnapshotException() { + super(); + } + + + /** + * Creates a new SnapshotException instance with the specified detail message. + * @param msg the detail message. + */ + public SnapshotException(String msg) { + super(msg); + } +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/BlockAccessModesEnum.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/BlockAccessModesEnum.java new file mode 100644 index 00000000..37ce6dd4 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/BlockAccessModesEnum.java @@ -0,0 +1,14 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +/** + * + * @author navid + */ +public enum BlockAccessModesEnum { + READ_WRITE, WRITE, READ +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/ContentionManager.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/ContentionManager.java new file mode 100644 index 00000000..af21ee96 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/ContentionManager.java @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +import TransactionalIO.core.BlockDataStructure; +import TransactionalIO.core.ExtendedTransaction; +import TransactionalIO.core.GlobalOffset; +import TransactionalIO.core.TransactionalFile; +import java.util.Vector; + +/** + * + * @author navid + */ + +public interface ContentionManager { + + + public void resolveConflict(ExtendedTransaction me, ExtendedTransaction other, GlobalOffset obj); + public void resolveConflict(ExtendedTransaction me, ExtendedTransaction other, BlockDataStructure obj); + + public void resolveConflict(ExtendedTransaction me, Vector/**/ other, GlobalOffset obj); + public void resolveConflict(ExtendedTransaction me, Vector/**/ other, BlockDataStructure obj); + + public void resolveConflict(ExtendedTransaction me, GlobalOffset obj); + public void resolveConflict(ExtendedTransaction me, BlockDataStructure obj); + + public long getPriority(); + + + public void setPriority(long value); + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/FileAccessModesEum.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/FileAccessModesEum.java new file mode 100644 index 00000000..c956c781 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/FileAccessModesEum.java @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +import java.io.WriteAbortedException; + +/** + * + * @author navid + */ +public enum FileAccessModesEum { + READ_WRITE, APPEND, READ + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/OffsetDependency.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/OffsetDependency.java new file mode 100644 index 00000000..a0f85f1c --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/OffsetDependency.java @@ -0,0 +1,15 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +/** + * + * @author navid + */ +public enum OffsetDependency { + NO_ACCESS, NO_DEPENDENCY, WRITE_DEPENDENCY_1, WRITE_DEPENDENCY_2, READ_DEPENDENCY + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionStatu.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionStatu.java new file mode 100644 index 00000000..4aeee172 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionStatu.java @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +import TransactionalIO.core.ExtendedTransaction.Status; + +/** + * + * @author navid + */ +public interface TransactionStatu { + + public void abortThisSystem(); + public TransactionStatu getOtherSystem(); + public void setOtherSystem(TransactionStatu othersystem); + public boolean isActive(); + public boolean isCommitted(); + public boolean isAborted(); + +} diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionalProgram.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionalProgram.java new file mode 100644 index 00000000..40a25165 --- /dev/null +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/interfaces/TransactionalProgram.java @@ -0,0 +1,15 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package TransactionalIO.interfaces; + +/** + * + * @author navid + */ +public interface TransactionalProgram { + public void execute(); + +} diff --git a/Robust/Transactions/dstm2/-b b/Robust/Transactions/dstm2/-b new file mode 100644 index 00000000..e69de29b diff --git a/Robust/Transactions/dstm2/build-before-profiler.xml b/Robust/Transactions/dstm2/build-before-profiler.xml new file mode 100644 index 00000000..0e8a4743 --- /dev/null +++ b/Robust/Transactions/dstm2/build-before-profiler.xml @@ -0,0 +1,70 @@ + + + + + + Builds, tests, and runs the project JavaApplication1. + + + + diff --git a/Robust/Transactions/dstm2/build.xml b/Robust/Transactions/dstm2/build.xml new file mode 100644 index 00000000..219a0671 --- /dev/null +++ b/Robust/Transactions/dstm2/build.xml @@ -0,0 +1,71 @@ + + + + + + Builds, tests, and runs the project JavaApplication1. + + + + + diff --git a/Robust/Transactions/dstm2/hs_err_pid27741.log b/Robust/Transactions/dstm2/hs_err_pid27741.log new file mode 100644 index 00000000..c3561b38 --- /dev/null +++ b/Robust/Transactions/dstm2/hs_err_pid27741.log @@ -0,0 +1,273 @@ +# +# An unexpected error has been detected by HotSpot Virtual Machine: +# +# SIGSEGV (0xb) at pc=0xb77e67ec, pid=27741, tid=2980461456 +# +# Java VM: Java HotSpot(TM) Client VM (1.5.0_14-b03 mixed mode, sharing) +# Problematic frame: +# V [libjvm.so+0x1a27ec] +# + +--------------- T H R E A D --------------- + +Current thread (0x081a81f0): JavaThread "Thread-8" [_thread_in_vm, id=27761] + +siginfo:si_signo=11, si_errno=0, si_code=1, si_addr=0x0000008c + +Registers: +EAX=0x00000008, EBX=0xb79d134c, ECX=0x00000ffc, EDX=0xb1a62d5c +ESP=0xb1a62cf4, EBP=0xb1a62d2c, ESI=0x00000000, EDI=0x00000004 +EIP=0xb77e67ec, CR2=0x0000008c, EFLAGS=0x00210202 + +Top of Stack: (sp=0xb1a62cf4) +0xb1a62cf4: 081a81f0 b1a62cf8 90999ddb b77e10f7 +0xb1a62d04: 081a81f0 00000000 911c25b0 b1a62d1c +0xb1a62d14: b1a62d44 b2610b3b 88e4cde8 b7f589a8 +0xb1a62d24: 8ca5d5b0 081a81f0 b1a62d8c b7f5779a +0xb1a62d34: 081a82b0 b1a62d58 00000000 00000004 +0xb1a62d44: b1a62dec b2610b3b 0000a015 00000000 +0xb1a62d54: 00000000 b1a62d50 90997dc3 b1a62d7c +0xb1a62d64: 911bf418 00000000 00000004 0000a015 + +Instructions: (pc=0xb77e67ec) +0xb77e67dc: ff ff ff 8b 42 04 8b 75 10 83 c0 08 8d 54 72 0c +0xb77e67ec: 8b b0 84 00 00 00 8b 45 18 0f af fe 56 57 50 52 + +Stack: [0xb19e3000,0xb1a64000), sp=0xb1a62cf4, free space=511k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [libjvm.so+0x1a27ec] +C [libkooni.so+0x79a] Java_TransactionalIO_core_ExtendedTransaction_nativepwrite+0x8b +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub +V [libjvm.so+0x17b2bc] +V [libjvm.so+0x28ff98] +V [libjvm.so+0x17ab15] +V [libjvm.so+0x17abae] +V [libjvm.so+0x1f2b15] +V [libjvm.so+0x2f99f3] +V [libjvm.so+0x290ba8] +C [libpthread.so.0+0x54fb] + +Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) + 0x081a91e0 JavaThread "Thread-9" [_thread_blocked, id=27762] +=>0x081a81f0 JavaThread "Thread-8" [_thread_in_vm, id=27761] + 0x081a7218 JavaThread "Thread-7" [_thread_blocked, id=27760] + 0x081a6260 JavaThread "Thread-6" [_thread_blocked, id=27759] + 0x081a5270 JavaThread "Thread-5" [_thread_blocked, id=27758] + 0x081a4280 JavaThread "Thread-4" [_thread_in_native, id=27757] + 0x081a3290 JavaThread "Thread-3" [_thread_blocked, id=27756] + 0x081a22a0 JavaThread "Thread-2" [_thread_blocked, id=27755] + 0x081a1278 JavaThread "Thread-1" [_thread_blocked, id=27754] + 0x080a6980 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=27747] + 0x080a53d0 JavaThread "CompilerThread0" daemon [_thread_blocked, id=27746] + 0x080a4330 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=27745] + 0x0809d760 JavaThread "Finalizer" daemon [_thread_blocked, id=27744] + 0x0809ca80 JavaThread "Reference Handler" daemon [_thread_blocked, id=27743] + 0x0805cd58 JavaThread "main" [_thread_blocked, id=27741] + +Other Threads: + 0x0809b5f8 VMThread [id=27742] + 0x080a7e70 WatcherThread [id=27748] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + def new generation total 576K, used 532K [0x88950000, 0x889f0000, 0x88e30000) + eden space 512K, 96% used [0x88950000, 0x889cbd80, 0x889d0000) + from space 64K, 58% used [0x889e0000, 0x889e9518, 0x889f0000) + to space 64K, 0% used [0x889d0000, 0x889d0000, 0x889e0000) + tenured generation total 1408K, used 265K [0x88e30000, 0x88f90000, 0x8c950000) + the space 1408K, 18% used [0x88e30000, 0x88e72718, 0x88e72800, 0x88f90000) + compacting perm gen total 8192K, used 1111K [0x8c950000, 0x8d150000, 0x90950000) + the space 8192K, 13% used [0x8c950000, 0x8ca65e70, 0x8ca66000, 0x8d150000) + ro space 8192K, 68% used [0x90950000, 0x90ed2bd8, 0x90ed2c00, 0x91150000) + rw space 12288K, 48% used [0x91150000, 0x91721490, 0x91721600, 0x91d50000) + +Dynamic libraries: +08048000-08057000 r-xp 00000000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08057000-08059000 rwxp 0000e000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08059000-081c3000 rwxp 08059000 00:00 0 [heap] +88950000-889f0000 rwxp 88950000 00:00 0 +889f0000-88e30000 rwxp 889f0000 00:00 0 +88e30000-88f90000 rwxp 88e30000 00:00 0 +88f90000-8c950000 rwxp 88f90000 00:00 0 +8c950000-8d150000 rwxp 8c950000 00:00 0 +8d150000-90950000 rwxp 8d150000 00:00 0 +90950000-90ed3000 r-xs 00001000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +90ed3000-91150000 rwxp 90ed3000 00:00 0 +91150000-91722000 rwxp 00584000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91722000-91d50000 rwxp 91722000 00:00 0 +91d50000-91e20000 rwxp 00b56000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91e20000-92150000 rwxp 91e20000 00:00 0 +92150000-92154000 r-xs 00c26000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +92154000-92550000 rwxp 92154000 00:00 0 +b1800000-b1821000 rwxp b1800000 00:00 0 +b1821000-b1900000 ---p b1821000 00:00 0 +b1962000-b1965000 ---p b1962000 00:00 0 +b1965000-b19e3000 rwxp b1965000 00:00 0 +b19e3000-b19e6000 ---p b19e3000 00:00 0 +b19e6000-b1a64000 rwxp b19e6000 00:00 0 +b1a64000-b1a67000 ---p b1a64000 00:00 0 +b1a67000-b1ae5000 rwxp b1a67000 00:00 0 +b1ae5000-b1ae8000 ---p b1ae5000 00:00 0 +b1ae8000-b1b66000 rwxp b1ae8000 00:00 0 +b1b66000-b1b69000 ---p b1b66000 00:00 0 +b1b69000-b1be7000 rwxp b1b69000 00:00 0 +b1be7000-b1bea000 ---p b1be7000 00:00 0 +b1bea000-b1c68000 rwxp b1bea000 00:00 0 +b1c68000-b1c6b000 ---p b1c68000 00:00 0 +b1c6b000-b1ce9000 rwxp b1c6b000 00:00 0 +b1ce9000-b1cec000 ---p b1ce9000 00:00 0 +b1cec000-b1d6a000 rwxp b1cec000 00:00 0 +b1d6a000-b1d6d000 ---p b1d6a000 00:00 0 +b1d6d000-b1deb000 rwxp b1d6d000 00:00 0 +b1deb000-b1dee000 rwxp b1deb000 00:00 0 +b1dee000-b1e6c000 rwxp b1dee000 00:00 0 +b1e6c000-b1e6d000 r-xp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1e6d000-b1e6e000 rwxp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1e6e000-b1e99000 r-xs 00000000 00:12 21938239 /home/navid/TransactionalIO/dist/TransactionalIO.jar +b1e99000-b1f1c000 r-xs 00000000 00:12 19730820 /home/navid/dstm2-release/bcel/bcel-5.2/bcel-5.2.jar +b1f1c000-b1f1f000 r-xs 00000000 08:01 15257714 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/dnsns.jar +b1f1f000-b1fe5000 r-xs 00000000 08:01 15257715 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/localedata.jar +b1fe5000-b200c000 r-xs 00000000 08:01 15257713 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunjce_provider.jar +b200c000-b2037000 r-xs 00000000 08:01 15257763 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunpkcs11.jar +b2037000-b2038000 ---p b2037000 00:00 0 +b2038000-b20b8000 rwxp b2038000 00:00 0 +b20b8000-b20bb000 ---p b20b8000 00:00 0 +b20bb000-b2139000 rwxp b20bb000 00:00 0 +b2139000-b213c000 ---p b2139000 00:00 0 +b213c000-b21ba000 rwxp b213c000 00:00 0 +b21ba000-b21bd000 ---p b21ba000 00:00 0 +b21bd000-b223b000 rwxp b21bd000 00:00 0 +b223b000-b2375000 r-xp 00000000 08:01 14418247 /usr/lib/locale/locale-archive +b2375000-b2378000 ---p b2375000 00:00 0 +b2378000-b23f6000 rwxp b2378000 00:00 0 +b23f6000-b23f9000 ---p b23f6000 00:00 0 +b23f9000-b2477000 rwxp b23f9000 00:00 0 +b2477000-b2478000 ---p b2477000 00:00 0 +b2478000-b2509000 rwxp b2478000 00:00 0 +b2509000-b2525000 rwxp b2509000 00:00 0 +b2525000-b2526000 rwxp b2525000 00:00 0 +b2526000-b2543000 rwxp b2526000 00:00 0 +b2543000-b2544000 rwxp b2543000 00:00 0 +b2544000-b2545000 rwxp b2544000 00:00 0 +b2545000-b2547000 rwxp b2545000 00:00 0 +b2547000-b2563000 rwxp b2547000 00:00 0 +b2563000-b2567000 rwxp b2563000 00:00 0 +b2567000-b2583000 rwxp b2567000 00:00 0 +b2583000-b2591000 rwxp b2583000 00:00 0 +b2591000-b260e000 rwxp b2591000 00:00 0 +b260e000-b26be000 rwxp b260e000 00:00 0 +b26be000-b460e000 rwxp b26be000 00:00 0 +b460e000-b4e7d000 r-xs 00000000 08:01 15257723 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/charsets.jar +b4e7d000-b4e92000 r-xs 00000000 08:01 15257716 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jce.jar +b4e92000-b4f17000 r-xs 00000000 08:01 15257711 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jsse.jar +b4f17000-b4f80000 rwxp b4f17000 00:00 0 +b4f80000-b75aa000 r-xs 00000000 08:01 15257790 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/rt.jar +b75aa000-b75b9000 r-xp 00000000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b75b9000-b75bb000 rwxp 0000e000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b75bb000-b75dc000 r-xp 00000000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b75dc000-b75de000 rwxp 00020000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b75de000-b75e7000 r-xp 00000000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b75e7000-b75e9000 rwxp 00008000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b75e9000-b75f1000 r-xp 00000000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b75f1000-b75f3000 rwxp 00007000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b75f3000-b7607000 r-xp 00000000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b7607000-b7609000 rwxp 00013000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b7609000-b760b000 rwxp b7609000 00:00 0 +b760b000-b7616000 r-xp 00000000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b7616000-b7617000 rwxp 0000b000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b7617000-b761f000 rwxs 00000000 08:01 16122659 /tmp/hsperfdata_navid/27741 +b761f000-b7642000 r-xp 00000000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b7642000-b7644000 rwxp 00023000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b7644000-b79b6000 r-xp 00000000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b79b6000-b79d4000 rwxp 00372000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b79d4000-b7dec000 rwxp b79d4000 00:00 0 +b7dec000-b7f34000 r-xp 00000000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f34000-b7f35000 r-xp 00148000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f35000-b7f37000 rwxp 00149000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f37000-b7f3b000 rwxp b7f37000 00:00 0 +b7f3b000-b7f3d000 r-xp 00000000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7f3d000-b7f3f000 rwxp 00001000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7f3f000-b7f53000 r-xp 00000000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7f53000-b7f55000 rwxp 00013000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7f55000-b7f57000 rwxp b7f55000 00:00 0 +b7f57000-b7f58000 r-xp 00000000 00:12 19467075 /home/navid/libkooni.so +b7f58000-b7f59000 rwxp 00000000 00:12 19467075 /home/navid/libkooni.so +b7f59000-b7f60000 r-xp 00000000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7f60000-b7f62000 rwxp 00006000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7f62000-b7f68000 r-xp 00000000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7f68000-b7f69000 rwxp 00006000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7f69000-b7f6a000 rwxp b7f69000 00:00 0 +b7f6a000-b7f6b000 r-xp b7f6a000 00:00 0 +b7f6b000-b7f6d000 rwxp b7f6b000 00:00 0 +b7f6d000-b7f87000 r-xp 00000000 08:01 5357576 /lib/ld-2.7.so +b7f87000-b7f89000 rwxp 00019000 08:01 5357576 /lib/ld-2.7.so +bf847000-bf84a000 ---p bf847000 00:00 0 +bf84a000-bfa47000 rwxp bf84a000 00:00 0 [stack] +ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] + +VM Arguments: +java_command: dstm2.benchmark.Main_for_Book_BenchMArk -b dstm2.benchmark.FinancialTransaction +Launcher Type: SUN_STANDARD + +Environment Variables: +PATH=/usr/local/bin:/usr/bin:/bin:/usr/games +USERNAME=navid +LD_LIBRARY_PATH=/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/../lib/i386 +SHELL=/bin/bash +DISPLAY=:0.0 + +Signal Handlers: +SIGSEGV: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGBUS: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGFPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGPIPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGILL: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGUSR2: [libjvm.so+0x291420], sa_mask[0]=0x00000004, sa_flags=0x10000004 +SIGHUP: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGQUIT: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGTERM: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 + + +--------------- S Y S T E M --------------- + +OS:lenny/sid + +uname:Linux 2.6.22-3-686 #1 SMP Sun Feb 10 20:20:49 UTC 2008 i686 +libc:glibc 2.7 NPTL 2.7 +rlimit: STACK 8192k, CORE 0k, NPROC 8108, NOFILE 1024, AS infinity +load average:0.58 0.27 0.16 + +CPU:total 2 (cores per cpu 2, threads per core 1) family 6 model 15 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2 + +Memory: 4k page, physical 1025800k(14152k free), swap 2610520k(160544k free) + +vm_info: Java HotSpot(TM) Client VM (1.5.0_14-b03) for linux-x86, built on Oct 5 2007 01:55:14 by java_re with gcc 3.2.1-7a (J2SE release) + diff --git a/Robust/Transactions/dstm2/hs_err_pid27828.log b/Robust/Transactions/dstm2/hs_err_pid27828.log new file mode 100644 index 00000000..da6599b9 --- /dev/null +++ b/Robust/Transactions/dstm2/hs_err_pid27828.log @@ -0,0 +1,273 @@ +# +# An unexpected error has been detected by HotSpot Virtual Machine: +# +# SIGSEGV (0xb) at pc=0xb776e7ec, pid=27828, tid=2984197008 +# +# Java VM: Java HotSpot(TM) Client VM (1.5.0_14-b03 mixed mode, sharing) +# Problematic frame: +# V [libjvm.so+0x1a27ec] +# + +--------------- T H R E A D --------------- + +Current thread (0x08199da8): JavaThread "Thread-0" [_thread_in_vm, id=27839] + +siginfo:si_signo=11, si_errno=0, si_code=1, si_addr=0x0000008c + +Registers: +EAX=0x00000008, EBX=0xb795934c, ECX=0x00000ffc, EDX=0xb1df2cdc +ESP=0xb1df2c74, EBP=0xb1df2cac, ESI=0x00000000, EDI=0x00000004 +EIP=0xb776e7ec, CR2=0x0000008c, EFLAGS=0x00210202 + +Top of Stack: (sp=0xb1df2c74) +0xb1df2c74: 08199da8 b1df2c78 90999ddb b77690f7 +0xb1df2c84: 08199da8 00000000 911c25b0 b1df2c9c +0xb1df2c94: b1df2cc4 b2598b3b 88e4cde8 b7ee09a8 +0xb1df2ca4: 8ca5d5b0 08199da8 b1df2d0c b7edf79a +0xb1df2cb4: 08199e68 b1df2cd8 00000000 00000004 +0xb1df2cc4: b1df2d6c b2598b3b 00006419 00000000 +0xb1df2cd4: 00000000 b1df2cd0 90997dc3 b1df2cfc +0xb1df2ce4: 911bf418 00000000 00000004 00006419 + +Instructions: (pc=0xb776e7ec) +0xb776e7dc: ff ff ff 8b 42 04 8b 75 10 83 c0 08 8d 54 72 0c +0xb776e7ec: 8b b0 84 00 00 00 8b 45 18 0f af fe 56 57 50 52 + +Stack: [0xb1d73000,0xb1df4000), sp=0xb1df2c74, free space=511k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [libjvm.so+0x1a27ec] +C [libkooni.so+0x79a] Java_TransactionalIO_core_ExtendedTransaction_nativepwrite+0x8b +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub +V [libjvm.so+0x17b2bc] +V [libjvm.so+0x28ff98] +V [libjvm.so+0x17ab15] +V [libjvm.so+0x17abae] +V [libjvm.so+0x1f2b15] +V [libjvm.so+0x2f99f3] +V [libjvm.so+0x290ba8] +C [libpthread.so.0+0x54fb] + +Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) + 0x081a9200 JavaThread "Thread-9" [_thread_blocked, id=27848] + 0x081a8210 JavaThread "Thread-8" [_thread_blocked, id=27847] + 0x081a7220 JavaThread "Thread-7" [_thread_blocked, id=27846] + 0x081a5240 JavaThread "Thread-5" [_thread_blocked, id=27844] + 0x081a4250 JavaThread "Thread-4" [_thread_blocked, id=27843] + 0x081a3230 JavaThread "Thread-3" [_thread_blocked, id=27842] + 0x081a2260 JavaThread "Thread-2" [_thread_blocked, id=27841] + 0x081a10d0 JavaThread "Thread-1" [_thread_blocked, id=27840] +=>0x08199da8 JavaThread "Thread-0" [_thread_in_vm, id=27839] + 0x080a6980 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=27837] + 0x080a53d0 JavaThread "CompilerThread0" daemon [_thread_blocked, id=27836] + 0x080a4330 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=27835] + 0x0809d760 JavaThread "Finalizer" daemon [_thread_blocked, id=27834] + 0x0809ca80 JavaThread "Reference Handler" daemon [_thread_blocked, id=27833] + 0x0805cd58 JavaThread "main" [_thread_blocked, id=27828] + +Other Threads: + 0x0809b5f8 VMThread [id=27832] + 0x080a7e70 WatcherThread [id=27838] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + def new generation total 576K, used 86K [0x88950000, 0x889f0000, 0x88e30000) + eden space 512K, 4% used [0x88950000, 0x889559f0, 0x889d0000) + from space 64K, 100% used [0x889d0000, 0x889e0000, 0x889e0000) + to space 64K, 0% used [0x889e0000, 0x889e0000, 0x889f0000) + tenured generation total 1408K, used 476K [0x88e30000, 0x88f90000, 0x8c950000) + the space 1408K, 33% used [0x88e30000, 0x88ea70d0, 0x88ea7200, 0x88f90000) + compacting perm gen total 8192K, used 1111K [0x8c950000, 0x8d150000, 0x90950000) + the space 8192K, 13% used [0x8c950000, 0x8ca65e90, 0x8ca66000, 0x8d150000) + ro space 8192K, 68% used [0x90950000, 0x90ed2bd8, 0x90ed2c00, 0x91150000) + rw space 12288K, 48% used [0x91150000, 0x91721490, 0x91721600, 0x91d50000) + +Dynamic libraries: +08048000-08057000 r-xp 00000000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08057000-08059000 rwxp 0000e000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08059000-081d1000 rwxp 08059000 00:00 0 [heap] +88950000-889f0000 rwxp 88950000 00:00 0 +889f0000-88e30000 rwxp 889f0000 00:00 0 +88e30000-88f90000 rwxp 88e30000 00:00 0 +88f90000-8c950000 rwxp 88f90000 00:00 0 +8c950000-8d150000 rwxp 8c950000 00:00 0 +8d150000-90950000 rwxp 8d150000 00:00 0 +90950000-90ed3000 r-xs 00001000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +90ed3000-91150000 rwxp 90ed3000 00:00 0 +91150000-91722000 rwxp 00584000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91722000-91d50000 rwxp 91722000 00:00 0 +91d50000-91e20000 rwxp 00b56000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91e20000-92150000 rwxp 91e20000 00:00 0 +92150000-92154000 r-xs 00c26000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +92154000-92550000 rwxp 92154000 00:00 0 +b1700000-b1721000 rwxp b1700000 00:00 0 +b1721000-b1800000 ---p b1721000 00:00 0 +b18ea000-b18ed000 ---p b18ea000 00:00 0 +b18ed000-b196b000 rwxp b18ed000 00:00 0 +b196b000-b196e000 ---p b196b000 00:00 0 +b196e000-b19ec000 rwxp b196e000 00:00 0 +b19ec000-b19ef000 ---p b19ec000 00:00 0 +b19ef000-b1a6d000 rwxp b19ef000 00:00 0 +b1a6d000-b1a70000 rwxp b1a6d000 00:00 0 +b1a70000-b1aee000 rwxp b1a70000 00:00 0 +b1aee000-b1af1000 ---p b1aee000 00:00 0 +b1af1000-b1b6f000 rwxp b1af1000 00:00 0 +b1b6f000-b1b72000 ---p b1b6f000 00:00 0 +b1b72000-b1bf0000 rwxp b1b72000 00:00 0 +b1bf0000-b1bf3000 ---p b1bf0000 00:00 0 +b1bf3000-b1c71000 rwxp b1bf3000 00:00 0 +b1c71000-b1c74000 ---p b1c71000 00:00 0 +b1c74000-b1cf2000 rwxp b1c74000 00:00 0 +b1cf2000-b1cf5000 ---p b1cf2000 00:00 0 +b1cf5000-b1d73000 rwxp b1cf5000 00:00 0 +b1d73000-b1d76000 ---p b1d73000 00:00 0 +b1d76000-b1df4000 rwxp b1d76000 00:00 0 +b1df4000-b1df5000 r-xp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1df5000-b1df6000 rwxp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1df6000-b1e21000 r-xs 00000000 00:12 21938239 /home/navid/TransactionalIO/dist/TransactionalIO.jar +b1e21000-b1ea4000 r-xs 00000000 00:12 19730820 /home/navid/dstm2-release/bcel/bcel-5.2/bcel-5.2.jar +b1ea4000-b1ea7000 r-xs 00000000 08:01 15257714 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/dnsns.jar +b1ea7000-b1f6d000 r-xs 00000000 08:01 15257715 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/localedata.jar +b1f6d000-b1f94000 r-xs 00000000 08:01 15257713 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunjce_provider.jar +b1f94000-b1fbf000 r-xs 00000000 08:01 15257763 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunpkcs11.jar +b1fbf000-b1fc0000 ---p b1fbf000 00:00 0 +b1fc0000-b2040000 rwxp b1fc0000 00:00 0 +b2040000-b2043000 ---p b2040000 00:00 0 +b2043000-b20c1000 rwxp b2043000 00:00 0 +b20c1000-b20c4000 ---p b20c1000 00:00 0 +b20c4000-b2142000 rwxp b20c4000 00:00 0 +b2142000-b2145000 ---p b2142000 00:00 0 +b2145000-b21c3000 rwxp b2145000 00:00 0 +b21c3000-b22fd000 r-xp 00000000 08:01 14418247 /usr/lib/locale/locale-archive +b22fd000-b2300000 ---p b22fd000 00:00 0 +b2300000-b237e000 rwxp b2300000 00:00 0 +b237e000-b2381000 ---p b237e000 00:00 0 +b2381000-b23ff000 rwxp b2381000 00:00 0 +b23ff000-b2400000 ---p b23ff000 00:00 0 +b2400000-b2491000 rwxp b2400000 00:00 0 +b2491000-b24ad000 rwxp b2491000 00:00 0 +b24ad000-b24ae000 rwxp b24ad000 00:00 0 +b24ae000-b24cb000 rwxp b24ae000 00:00 0 +b24cb000-b24cc000 rwxp b24cb000 00:00 0 +b24cc000-b24cd000 rwxp b24cc000 00:00 0 +b24cd000-b24cf000 rwxp b24cd000 00:00 0 +b24cf000-b24eb000 rwxp b24cf000 00:00 0 +b24eb000-b24ef000 rwxp b24eb000 00:00 0 +b24ef000-b250b000 rwxp b24ef000 00:00 0 +b250b000-b2519000 rwxp b250b000 00:00 0 +b2519000-b2596000 rwxp b2519000 00:00 0 +b2596000-b2646000 rwxp b2596000 00:00 0 +b2646000-b4596000 rwxp b2646000 00:00 0 +b4596000-b4e05000 r-xs 00000000 08:01 15257723 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/charsets.jar +b4e05000-b4e1a000 r-xs 00000000 08:01 15257716 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jce.jar +b4e1a000-b4e9f000 r-xs 00000000 08:01 15257711 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jsse.jar +b4e9f000-b4f08000 rwxp b4e9f000 00:00 0 +b4f08000-b7532000 r-xs 00000000 08:01 15257790 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/rt.jar +b7532000-b7541000 r-xp 00000000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b7541000-b7543000 rwxp 0000e000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b7543000-b7564000 r-xp 00000000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b7564000-b7566000 rwxp 00020000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b7566000-b756f000 r-xp 00000000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b756f000-b7571000 rwxp 00008000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b7571000-b7579000 r-xp 00000000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b7579000-b757b000 rwxp 00007000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b757b000-b758f000 r-xp 00000000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b758f000-b7591000 rwxp 00013000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b7591000-b7593000 rwxp b7591000 00:00 0 +b7593000-b759e000 r-xp 00000000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b759e000-b759f000 rwxp 0000b000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b759f000-b75a7000 rwxs 00000000 08:01 16122659 /tmp/hsperfdata_navid/27828 +b75a7000-b75ca000 r-xp 00000000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b75ca000-b75cc000 rwxp 00023000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b75cc000-b793e000 r-xp 00000000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b793e000-b795c000 rwxp 00372000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b795c000-b7d74000 rwxp b795c000 00:00 0 +b7d74000-b7ebc000 r-xp 00000000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7ebc000-b7ebd000 r-xp 00148000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7ebd000-b7ebf000 rwxp 00149000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7ebf000-b7ec3000 rwxp b7ebf000 00:00 0 +b7ec3000-b7ec5000 r-xp 00000000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7ec5000-b7ec7000 rwxp 00001000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7ec7000-b7edb000 r-xp 00000000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7edb000-b7edd000 rwxp 00013000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7edd000-b7edf000 rwxp b7edd000 00:00 0 +b7edf000-b7ee0000 r-xp 00000000 00:12 19467075 /home/navid/libkooni.so +b7ee0000-b7ee1000 rwxp 00000000 00:12 19467075 /home/navid/libkooni.so +b7ee1000-b7ee8000 r-xp 00000000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7ee8000-b7eea000 rwxp 00006000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7eea000-b7ef0000 r-xp 00000000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7ef0000-b7ef1000 rwxp 00006000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7ef1000-b7ef2000 rwxp b7ef1000 00:00 0 +b7ef2000-b7ef3000 r-xp b7ef2000 00:00 0 +b7ef3000-b7ef5000 rwxp b7ef3000 00:00 0 +b7ef5000-b7f0f000 r-xp 00000000 08:01 5357576 /lib/ld-2.7.so +b7f0f000-b7f11000 rwxp 00019000 08:01 5357576 /lib/ld-2.7.so +bf724000-bf727000 ---p bf724000 00:00 0 +bf727000-bf924000 rwxp bf727000 00:00 0 [stack] +ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] + +VM Arguments: +java_command: dstm2.benchmark.Main_for_Book_BenchMArk -b dstm2.benchmark.FinancialTransaction +Launcher Type: SUN_STANDARD + +Environment Variables: +PATH=/usr/local/bin:/usr/bin:/bin:/usr/games +USERNAME=navid +LD_LIBRARY_PATH=/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/../lib/i386 +SHELL=/bin/bash +DISPLAY=:0.0 + +Signal Handlers: +SIGSEGV: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGBUS: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGFPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGPIPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGILL: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGUSR2: [libjvm.so+0x291420], sa_mask[0]=0x00000004, sa_flags=0x10000004 +SIGHUP: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGQUIT: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGTERM: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 + + +--------------- S Y S T E M --------------- + +OS:lenny/sid + +uname:Linux 2.6.22-3-686 #1 SMP Sun Feb 10 20:20:49 UTC 2008 i686 +libc:glibc 2.7 NPTL 2.7 +rlimit: STACK 8192k, CORE 0k, NPROC 8108, NOFILE 1024, AS infinity +load average:0.16 0.21 0.14 + +CPU:total 2 (cores per cpu 2, threads per core 1) family 6 model 15 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2 + +Memory: 4k page, physical 1025800k(22628k free), swap 2610520k(160556k free) + +vm_info: Java HotSpot(TM) Client VM (1.5.0_14-b03) for linux-x86, built on Oct 5 2007 01:55:14 by java_re with gcc 3.2.1-7a (J2SE release) + diff --git a/Robust/Transactions/dstm2/hs_err_pid27887.log b/Robust/Transactions/dstm2/hs_err_pid27887.log new file mode 100644 index 00000000..7b599796 --- /dev/null +++ b/Robust/Transactions/dstm2/hs_err_pid27887.log @@ -0,0 +1,271 @@ +# +# An unexpected error has been detected by HotSpot Virtual Machine: +# +# SIGSEGV (0xb) at pc=0xb77de7ec, pid=27887, tid=2979900304 +# +# Java VM: Java HotSpot(TM) Client VM (1.5.0_14-b03 mixed mode, sharing) +# Problematic frame: +# V [libjvm.so+0x1a27ec] +# + +--------------- T H R E A D --------------- + +Current thread (0x081a9258): JavaThread "Thread-9" [_thread_in_vm, id=27904] + +siginfo:si_signo=11, si_errno=0, si_code=1, si_addr=0x0000008c + +Registers: +EAX=0x00000008, EBX=0xb79c934c, ECX=0x00000ffc, EDX=0xb19d9adc +ESP=0xb19d9a74, EBP=0xb19d9aac, ESI=0x00000000, EDI=0x00000005 +EIP=0xb77de7ec, CR2=0x0000008c, EFLAGS=0x00210202 + +Top of Stack: (sp=0xb19d9a74) +0xb19d9a74: 081a9258 b19d9a78 90999ddb b77d90f7 +0xb19d9a84: 081a9258 00000000 911c25b0 b19d9a9c +0xb19d9a94: b19d9ac4 b2608b3b 88e4cde8 b7f509a8 +0xb19d9aa4: 8ca5d5b0 081a9258 b19d9b0c b7f4f79a +0xb19d9ab4: 081a9318 b19d9ad8 00000000 00000005 +0xb19d9ac4: b19d9b6c b2608b3b 00008414 00000000 +0xb19d9ad4: 00000000 b19d9ad0 90997dc3 b19d9afc +0xb19d9ae4: 911bf418 00000000 00000005 00008414 + +Instructions: (pc=0xb77de7ec) +0xb77de7dc: ff ff ff 8b 42 04 8b 75 10 83 c0 08 8d 54 72 0c +0xb77de7ec: 8b b0 84 00 00 00 8b 45 18 0f af fe 56 57 50 52 + +Stack: [0xb195a000,0xb19db000), sp=0xb19d9a74, free space=510k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [libjvm.so+0x1a27ec] +C [libkooni.so+0x79a] Java_TransactionalIO_core_ExtendedTransaction_nativepwrite+0x8b +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub +V [libjvm.so+0x17b2bc] +V [libjvm.so+0x28ff98] +V [libjvm.so+0x17ab15] +V [libjvm.so+0x17abae] +V [libjvm.so+0x1f2b15] +V [libjvm.so+0x2f99f3] +V [libjvm.so+0x290ba8] +C [libpthread.so.0+0x54fb] + +Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) +j TransactionalIO.core.ExtendedTransaction.nativepwrite([BJILjava/io/FileDescriptor;)I+0 +j TransactionalIO.core.ExtendedTransaction.invokeNativepwrite([BJILjava/io/RandomAccessFile;)I+18 +j TransactionalIO.core.ExtendedTransaction.commitChanges()V+202 +j TransactionalIO.core.Wrapper.commitIO()V+3 +j dstm2.Thread.doIt(Ljava/util/concurrent/Callable;)Ljava/lang/Object;+129 +j dstm2.benchmark.CustomThread.financialBenchmark()V+380 +j dstm2.benchmark.CustomThread.run()V+28 +j dstm2.Thread$3.run()V+18 +j java.lang.Thread.run()V+11 +v ~StubRoutines::call_stub + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) +=>0x081a9258 JavaThread "Thread-9" [_thread_in_vm, id=27904] + 0x081a8280 JavaThread "Thread-8" [_thread_blocked, id=27903] + 0x081aa3d0 JavaThread "Thread-7" [_thread_blocked, id=27902] + 0x081a6b58 JavaThread "Thread-6" [_thread_blocked, id=27901] + 0x081a5218 JavaThread "Thread-5" [_thread_blocked, id=27900] + 0x081a4228 JavaThread "Thread-4" [_thread_blocked, id=27899] + 0x081a2248 JavaThread "Thread-2" [_thread_blocked, id=27897] + 0x081a1070 JavaThread "Thread-1" [_thread_blocked, id=27896] + 0x08199380 JavaThread "Thread-0" [_thread_blocked, id=27895] + 0x080a6980 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=27893] + 0x080a53d0 JavaThread "CompilerThread0" daemon [_thread_blocked, id=27892] + 0x080a4330 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=27891] + 0x0809d760 JavaThread "Finalizer" daemon [_thread_blocked, id=27890] + 0x0809ca48 JavaThread "Reference Handler" daemon [_thread_blocked, id=27889] + 0x0805cd58 JavaThread "main" [_thread_blocked, id=27887] + +Other Threads: + 0x0809b5f8 VMThread [id=27888] + 0x080a7e70 WatcherThread [id=27894] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + def new generation total 576K, used 106K [0x88950000, 0x889f0000, 0x88e30000) + eden space 512K, 8% used [0x88950000, 0x8895aba8, 0x889d0000) + from space 64K, 100% used [0x889d0000, 0x889e0000, 0x889e0000) + to space 64K, 0% used [0x889e0000, 0x889e0000, 0x889f0000) + tenured generation total 1408K, used 500K [0x88e30000, 0x88f90000, 0x8c950000) + the space 1408K, 35% used [0x88e30000, 0x88ead340, 0x88ead400, 0x88f90000) + compacting perm gen total 8192K, used 1111K [0x8c950000, 0x8d150000, 0x90950000) + the space 8192K, 13% used [0x8c950000, 0x8ca65eb0, 0x8ca66000, 0x8d150000) + ro space 8192K, 68% used [0x90950000, 0x90ed2bd8, 0x90ed2c00, 0x91150000) + rw space 12288K, 48% used [0x91150000, 0x91721490, 0x91721600, 0x91d50000) + +Dynamic libraries: +08048000-08057000 r-xp 00000000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08057000-08059000 rwxp 0000e000 08:01 15269937 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/java +08059000-081c3000 rwxp 08059000 00:00 0 [heap] +88950000-889f0000 rwxp 88950000 00:00 0 +889f0000-88e30000 rwxp 889f0000 00:00 0 +88e30000-88f90000 rwxp 88e30000 00:00 0 +88f90000-8c950000 rwxp 88f90000 00:00 0 +8c950000-8d150000 rwxp 8c950000 00:00 0 +8d150000-90950000 rwxp 8d150000 00:00 0 +90950000-90ed3000 r-xs 00001000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +90ed3000-91150000 rwxp 90ed3000 00:00 0 +91150000-91722000 rwxp 00584000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91722000-91d50000 rwxp 91722000 00:00 0 +91d50000-91e20000 rwxp 00b56000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +91e20000-92150000 rwxp 91e20000 00:00 0 +92150000-92154000 r-xs 00c26000 08:01 15270044 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/classes.jsa +92154000-92550000 rwxp 92154000 00:00 0 +b195a000-b195d000 ---p b195a000 00:00 0 +b195d000-b19db000 rwxp b195d000 00:00 0 +b19db000-b19de000 ---p b19db000 00:00 0 +b19de000-b1a5c000 rwxp b19de000 00:00 0 +b1a5c000-b1a5f000 ---p b1a5c000 00:00 0 +b1a5f000-b1add000 rwxp b1a5f000 00:00 0 +b1add000-b1ae0000 ---p b1add000 00:00 0 +b1ae0000-b1b5e000 rwxp b1ae0000 00:00 0 +b1b5e000-b1b61000 ---p b1b5e000 00:00 0 +b1b61000-b1bdf000 rwxp b1b61000 00:00 0 +b1bdf000-b1be2000 ---p b1bdf000 00:00 0 +b1be2000-b1c60000 rwxp b1be2000 00:00 0 +b1c60000-b1c63000 rwxp b1c60000 00:00 0 +b1c63000-b1ce1000 rwxp b1c63000 00:00 0 +b1ce1000-b1ce4000 ---p b1ce1000 00:00 0 +b1ce4000-b1d62000 rwxp b1ce4000 00:00 0 +b1d62000-b1d65000 ---p b1d62000 00:00 0 +b1d65000-b1de3000 rwxp b1d65000 00:00 0 +b1de3000-b1de6000 ---p b1de3000 00:00 0 +b1de6000-b1e64000 rwxp b1de6000 00:00 0 +b1e64000-b1e65000 r-xp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1e65000-b1e66000 rwxp 00000000 00:12 19466915 /home/navid/libnativeIO.so +b1e66000-b1e91000 r-xs 00000000 00:12 21938239 /home/navid/TransactionalIO/dist/TransactionalIO.jar +b1e91000-b1f14000 r-xs 00000000 00:12 19730820 /home/navid/dstm2-release/bcel/bcel-5.2/bcel-5.2.jar +b1f14000-b1f17000 r-xs 00000000 08:01 15257714 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/dnsns.jar +b1f17000-b1fdd000 r-xs 00000000 08:01 15257715 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/localedata.jar +b1fdd000-b2004000 r-xs 00000000 08:01 15257713 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunjce_provider.jar +b2004000-b202f000 r-xs 00000000 08:01 15257763 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/ext/sunpkcs11.jar +b202f000-b2030000 ---p b202f000 00:00 0 +b2030000-b20b0000 rwxp b2030000 00:00 0 +b20b0000-b20b3000 ---p b20b0000 00:00 0 +b20b3000-b2131000 rwxp b20b3000 00:00 0 +b2131000-b2134000 ---p b2131000 00:00 0 +b2134000-b21b2000 rwxp b2134000 00:00 0 +b21b2000-b21b5000 ---p b21b2000 00:00 0 +b21b5000-b2233000 rwxp b21b5000 00:00 0 +b2233000-b236d000 r-xp 00000000 08:01 14418247 /usr/lib/locale/locale-archive +b236d000-b2370000 ---p b236d000 00:00 0 +b2370000-b23ee000 rwxp b2370000 00:00 0 +b23ee000-b23f1000 ---p b23ee000 00:00 0 +b23f1000-b246f000 rwxp b23f1000 00:00 0 +b246f000-b2470000 ---p b246f000 00:00 0 +b2470000-b2501000 rwxp b2470000 00:00 0 +b2501000-b251d000 rwxp b2501000 00:00 0 +b251d000-b251e000 rwxp b251d000 00:00 0 +b251e000-b253b000 rwxp b251e000 00:00 0 +b253b000-b253c000 rwxp b253b000 00:00 0 +b253c000-b253d000 rwxp b253c000 00:00 0 +b253d000-b253f000 rwxp b253d000 00:00 0 +b253f000-b255b000 rwxp b253f000 00:00 0 +b255b000-b255f000 rwxp b255b000 00:00 0 +b255f000-b257b000 rwxp b255f000 00:00 0 +b257b000-b2589000 rwxp b257b000 00:00 0 +b2589000-b2606000 rwxp b2589000 00:00 0 +b2606000-b26b6000 rwxp b2606000 00:00 0 +b26b6000-b4606000 rwxp b26b6000 00:00 0 +b4606000-b4e75000 r-xs 00000000 08:01 15257723 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/charsets.jar +b4e75000-b4e8a000 r-xs 00000000 08:01 15257716 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jce.jar +b4e8a000-b4f0f000 r-xs 00000000 08:01 15257711 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/jsse.jar +b4f0f000-b4f78000 rwxp b4f0f000 00:00 0 +b4f78000-b75a2000 r-xs 00000000 08:01 15257790 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/rt.jar +b75a2000-b75b1000 r-xp 00000000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b75b1000-b75b3000 rwxp 0000e000 08:01 15257733 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libzip.so +b75b3000-b75d4000 r-xp 00000000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b75d4000-b75d6000 rwxp 00020000 08:01 15257732 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libjava.so +b75d6000-b75df000 r-xp 00000000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b75df000-b75e1000 rwxp 00008000 08:01 5357751 /lib/i686/cmov/libnss_files-2.7.so +b75e1000-b75e9000 r-xp 00000000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b75e9000-b75eb000 rwxp 00007000 08:01 5357777 /lib/i686/cmov/libnss_nis-2.7.so +b75eb000-b75ff000 r-xp 00000000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b75ff000-b7601000 rwxp 00013000 08:01 5357730 /lib/i686/cmov/libnsl-2.7.so +b7601000-b7603000 rwxp b7601000 00:00 0 +b7603000-b760e000 r-xp 00000000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b760e000-b760f000 rwxp 0000b000 08:01 15257731 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/libverify.so +b760f000-b7617000 rwxs 00000000 08:01 16122660 /tmp/hsperfdata_navid/27887 +b7617000-b763a000 r-xp 00000000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b763a000-b763c000 rwxp 00023000 08:01 5357724 /lib/i686/cmov/libm-2.7.so +b763c000-b79ae000 r-xp 00000000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b79ae000-b79cc000 rwxp 00372000 08:01 15269960 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client/libjvm.so +b79cc000-b7de4000 rwxp b79cc000 00:00 0 +b7de4000-b7f2c000 r-xp 00000000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f2c000-b7f2d000 r-xp 00148000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f2d000-b7f2f000 rwxp 00149000 08:01 5357719 /lib/i686/cmov/libc-2.7.so +b7f2f000-b7f33000 rwxp b7f2f000 00:00 0 +b7f33000-b7f35000 r-xp 00000000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7f35000-b7f37000 rwxp 00001000 08:01 5357723 /lib/i686/cmov/libdl-2.7.so +b7f37000-b7f4b000 r-xp 00000000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7f4b000-b7f4d000 rwxp 00013000 08:01 5357878 /lib/i686/cmov/libpthread-2.7.so +b7f4d000-b7f4f000 rwxp b7f4d000 00:00 0 +b7f4f000-b7f50000 r-xp 00000000 00:12 19467075 /home/navid/libkooni.so +b7f50000-b7f51000 rwxp 00000000 00:12 19467075 /home/navid/libkooni.so +b7f51000-b7f58000 r-xp 00000000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7f58000-b7f5a000 rwxp 00006000 08:01 5357742 /lib/i686/cmov/libnss_compat-2.7.so +b7f5a000-b7f60000 r-xp 00000000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7f60000-b7f61000 rwxp 00006000 08:01 15269955 /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/native_threads/libhpi.so +b7f61000-b7f62000 rwxp b7f61000 00:00 0 +b7f62000-b7f63000 r-xp b7f62000 00:00 0 +b7f63000-b7f65000 rwxp b7f63000 00:00 0 +b7f65000-b7f7f000 r-xp 00000000 08:01 5357576 /lib/ld-2.7.so +b7f7f000-b7f81000 rwxp 00019000 08:01 5357576 /lib/ld-2.7.so +bfbe6000-bfbe9000 ---p bfbe6000 00:00 0 +bfbe9000-bfde6000 rwxp bfbe9000 00:00 0 [stack] +ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] + +VM Arguments: +java_command: dstm2.benchmark.Main_for_Book_BenchMArk -b dstm2.benchmark.FinancialTransaction +Launcher Type: SUN_STANDARD + +Environment Variables: +PATH=/usr/local/bin:/usr/bin:/bin:/usr/games +USERNAME=navid +LD_LIBRARY_PATH=/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/../lib/i386 +SHELL=/bin/bash +DISPLAY=:0.0 + +Signal Handlers: +SIGSEGV: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGBUS: [libjvm.so+0x32b7d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGFPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGPIPE: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGILL: [libjvm.so+0x28efd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGUSR2: [libjvm.so+0x291420], sa_mask[0]=0x00000004, sa_flags=0x10000004 +SIGHUP: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000 +SIGQUIT: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 +SIGTERM: [libjvm.so+0x290e50], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 + + +--------------- S Y S T E M --------------- + +OS:lenny/sid + +uname:Linux 2.6.22-3-686 #1 SMP Sun Feb 10 20:20:49 UTC 2008 i686 +libc:glibc 2.7 NPTL 2.7 +rlimit: STACK 8192k, CORE 0k, NPROC 8108, NOFILE 1024, AS infinity +load average:0.14 0.20 0.14 + +CPU:total 2 (cores per cpu 2, threads per core 1) family 6 model 15 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2 + +Memory: 4k page, physical 1025800k(22112k free), swap 2610520k(160556k free) + +vm_info: Java HotSpot(TM) Client VM (1.5.0_14-b03) for linux-x86, built on Oct 5 2007 01:55:14 by java_re with gcc 3.2.1-7a (J2SE release) + diff --git a/Robust/Transactions/dstm2/manifest.mf b/Robust/Transactions/dstm2/manifest.mf new file mode 100644 index 00000000..328e8e5b --- /dev/null +++ b/Robust/Transactions/dstm2/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Robust/Transactions/dstm2/src/dstm2/AtomicArray.java b/Robust/Transactions/dstm2/src/dstm2/AtomicArray.java new file mode 100644 index 00000000..e38017c4 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/AtomicArray.java @@ -0,0 +1,181 @@ +package dstm2; + +/* + * AtomicArray.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + + + +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.exceptions.PanicException; +import dstm2.factory.ofree.ReadSet; +import java.lang.reflect.Array; + +/** + * @author mph + */ +@atomic public class AtomicArray { + + private final T[] array; + private final T[] shadow; + private Transaction writer; + private ReadSet readers; + long version; + private final String FORMAT = "Unexpected transaction state: %s"; + + /** Creates a new instance of AtomicArray */ + public AtomicArray(Class _class, int capacity) { + array = (T[]) Array.newInstance(_class, capacity); + shadow = (T[]) Array.newInstance(_class, capacity); + writer = Transaction.COMMITTED; + readers = new ReadSet(); + version = 0; + } + + public T get(int i) { + Transaction me = Thread.getTransaction(); + Transaction other = null; + ContentionManager manager = Thread.getContentionManager(); + while (true) { + synchronized (this) { + other = openRead(me); + if (other == null) { + return array[i]; + } + } + manager.resolveConflict(me, other); + } + } + + public void set(int i, T value) { + Transaction me = Thread.getTransaction(); + Transaction other = null; + ContentionManager manager = Thread.getContentionManager(); + while (true) { + synchronized (this) { + other = openWrite(me); + if (other == null) { + array[i] = value; + return; + } + } + manager.resolveConflict(me, other); + } + } + /** + * Tries to open object for reading. Returns reference to conflictin transaction, if one exists + **/ + private Transaction openRead(Transaction me) { + // not in a transaction + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + restore(); + version++; + writer = Transaction.COMMITTED; + } + return null; + } + // Am I still active? + if (!me.isActive()) { + throw new AbortedException(); + } + // Have I already opened this object? + if (writer == me) { + return null; + } + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + break; + case ABORTED: + restore(); + version++; + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = Transaction.COMMITTED; + readers.add(me); + return null; + } + + /** + * Tries to open object for reading. Returns reference to conflicting transaction, if one exists + **/ + public Transaction openWrite(Transaction me) { + // not in a transaction + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + restore(); + version++; + writer = Transaction.COMMITTED; + } + return null; + } + if (!me.validate()) { + throw new AbortedException(); + } + if (me == writer) { + return null; + } + for (Transaction reader : readers) { + if (reader.isActive() && reader != me) { + return reader; + } + } + readers.clear(); + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + backup(); + version++; + break; + case ABORTED: + restore(); + version++; + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = me; + return null; + } + + private void restore() { + System.arraycopy(shadow, 0, array, 0, array.length); + } + private void backup() { + System.arraycopy(array, 0, shadow, 0, array.length); + } + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/ContentionManager.java b/Robust/Transactions/dstm2/src/dstm2/ContentionManager.java new file mode 100644 index 00000000..ed342192 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/ContentionManager.java @@ -0,0 +1,77 @@ +/* + * ContentionManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import dstm2.*; +import java.util.Collection; +/** + * Interface satisfied by all contention managers + */ +public interface ContentionManager { + /** + * Either give the writer a chance to finish it, abort it, or both. + * @param me Calling transaction. + * @param other Transaction that's in my way. + */ + void resolveConflict(Transaction me, Transaction other); + + /** + * Either give the writer a chance to finish it, abort it, or both. + * @param me Calling transaction. + * @param other set of transactions in my way + */ + void resolveConflict(Transaction me, Collection other); + + /** + * Assign a priority to caller. Not all managers assign meaningful priorities. + * @return Priority of conflicting transaction. + */ + long getPriority(); + + /** + * Change this manager's priority. + * @param value new priority value + */ + void setPriority(long value); + + /** + * Notify manager that object was opened. + */ + void openSucceeded(); + + /** + * Notify manager that transaction committed. + */ + void committed(); + +}; diff --git a/Robust/Transactions/dstm2/src/dstm2/Defaults.java b/Robust/Transactions/dstm2/src/dstm2/Defaults.java new file mode 100644 index 00000000..a5dae56e --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/Defaults.java @@ -0,0 +1,65 @@ +/* + * Defaults.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +/** + * + * @author Maurice Herlihy + */ +public class Defaults { + /** + * how many threads + **/ + public static final int THREADS = 5; + /** + * benchmark duration in milliseconds + **/ + public static final int TIME = 10000; + /** + * uninterpreted arg passed to benchmark + **/ + public static final int EXPERIMENT = 100; + /** + * fully-qualified contention manager name + **/ + public static final String MANAGER = "dstm2.manager.BackoffManager"; + /** + * fully-qualified factory name + **/ + public static final String FACTORY = "dstm2.factory.shadow.Factory"; + /** + * fully-qualified adapter name + **/ + public static final String ADAPTER = "dstm2.factory.shadow.Adapter";; + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/Main.java b/Robust/Transactions/dstm2/src/dstm2/Main.java new file mode 100644 index 00000000..1e23a80f --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/Main.java @@ -0,0 +1,179 @@ +/* + * Main.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; +import static dstm2.Defaults.*; +import dstm2.benchmark.Benchmark; +import TransactionalIO.exceptions.PanicException; +import dstm2.factory.Factory; + +public class Main { + + /** + * @param args the command line arguments + * usage: dstm.benchmark.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-f " + */ + public static void main(String args[]) { + int numThreads = 20;//THREADS; + int numMillis = TIME; + int experiment = EXPERIMENT; + String managerClassName = MANAGER; + Class managerClass = null; + String benchmarkClassName = null; + Class benchmarkClass = null; + + String adapterClassName = Defaults.ADAPTER; + + // discard statistics from previous runs + Thread.clear(); + // Parse and check the args + int argc = 0; + try { + while (argc < args.length) { + String option = args[argc++]; + if (option.equals("-m")) + managerClassName = args[argc]; + else if (option.equals("-b")) + benchmarkClassName = args[argc]; + else if (option.equals("-t")) + numThreads = Integer.parseInt(args[argc]); + else if (option.equals("-n")) + numMillis = Integer.parseInt(args[argc]); + else if (option.equals("-e")) + experiment = Integer.parseInt(args[argc]); + else if (option.equals("-a")) + adapterClassName = args[argc]; + else + reportUsageErrorAndDie(); + argc++; + } + } catch (NumberFormatException e) { + System.out.println("Expected a number: " + args[argc]); + System.exit(0); + } catch (Exception e) { + reportUsageErrorAndDie(); + } + + // Initialize contention manager. + try { + managerClass = Class.forName(MANAGER); + Thread.setContentionManagerClass(managerClass); + } catch (ClassNotFoundException ex) { + reportUsageErrorAndDie(); + } + + // Initialize adapter class + Thread.setAdapterClass(adapterClassName); + + // initialize benchmark + Benchmark benchmark = null; + try { + benchmarkClass = Class.forName(benchmarkClassName); + benchmark = (Benchmark) benchmarkClass.newInstance(); + } catch (InstantiationException e) { + System.out.format("%s does not implement dstm.benchmark.Benchmark: %s\n", benchmarkClass, e); + System.exit(0); + } catch (ClassCastException e) { + System.out.format("Exception when creating class %s: %s\n", benchmarkClass, e); + System.exit(0); + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + + // Set up the benchmark + long startTime = 0; + + Thread[] thread = new Thread[numThreads]; + System.out.println("Benchmark: " + benchmarkClass); + System.out.println("Adapter: " + adapterClassName); + System.out.println("Contention manager: " + managerClassName); + System.out.println("Threads: " + numThreads); + System.out.println("Mix: " + experiment + "% updates"); + + + TransactionalIO.benchmarks.benchmark.init(); + + System.out.println((char)97); + int j = 97; + try { + for (int i = 0; i < numThreads; i++){ + System.out.println((char)j); + thread[i] = benchmark.createThread(experiment, (char)j); + j++; + } + + startTime = System.currentTimeMillis(); + for (int i = 0; i < numThreads; i++) + thread[i].start(); + Thread.sleep(numMillis); + Thread.stop = true; // notify threads to stop + for (int i = 0; i < numThreads; i++) { + thread[i].join(); + } + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + long stopTime = System.currentTimeMillis(); + + double elapsed = (double)(stopTime - startTime) / 1000.0; + + // Run the sanity check for this benchmark + try { + benchmark.sanityCheck(); + } catch (Exception e) { + e.printStackTrace(System.out); + } + + long committed = Thread.totalCommitted; + long total = Thread.totalTotal; + if (total > 0) { + System.out.printf("Committed: %d\nTotal: %d\nPercent committed: (%d%%)\n", + committed, + total, + (100 * committed) / total); + } else { + System.out.println("No transactions executed!"); + } + benchmark.report(); + System.out.println("Elapsed time: " + elapsed + " seconds."); + System.out.println("----------------------------------------"); + } + + private static void reportUsageErrorAndDie() { + System.out.println("usage: dstm2.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-a ]"); + System.exit(0); + } + +} + diff --git a/Robust/Transactions/dstm2/src/dstm2/Thread.java b/Robust/Transactions/dstm2/src/dstm2/Thread.java new file mode 100644 index 00000000..adf02fac --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/Thread.java @@ -0,0 +1,610 @@ +package dstm2; + +/* + * Thread.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +//package dstm2; + + +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.exceptions.GracefulException; +import TransactionalIO.exceptions.PanicException; + +import dstm2.factory.AtomicFactory; +import dstm2.factory.Factory; +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.core.TransactionalFile; +import TransactionalIO.core.Wrapper; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import static dstm2.Defaults.*; +/** + * The basic unit of computation for the transactional memory. This + * class extends java.lang.Thread by providing methods to + * begin, commit and abort transactions. + * + * Every Thread has a contention manager, created when + * the thread is created. Before creating any Threads, + * you must call Thread.setContentionManager to set the + * class of the contention manager that will be created. The + * contention manager of a thread is notified (by invoking its + * notification methods) of the results of any methods involving the + * thread. It is also consulted on whether a transaction should be + * begun. + * + * @see dstm2.ContentionManager + */ +public class Thread extends java.lang.Thread { + /** + * Contention manager class. + */ + protected static Class contentionManagerClass; + + /** + * Adapter class. + */ + protected static Class adapterClass; + + /** + * Set to true when benchmark runs out of time. + **/ + public static volatile boolean stop = false; + /** + * number of committed transactions for all threads + */ + public static long totalCommitted = 0; + /** + * total number of transactions for all threads + */ + public static long totalTotal = 0; + /** + * number of committed memory references for all threads + */ + public static long totalCommittedMemRefs = 0; + /** + * total number of memory references for all threads + */ + public static long totalTotalMemRefs = 0; + + static ThreadLocal _threadState = new ThreadLocal() { + protected synchronized ThreadState initialValue() { + return new ThreadState(); + } + }; + static ThreadLocal _thread = new ThreadLocal() { + protected synchronized Thread initialValue() { + return null; + } + }; + + private static int MAX_NESTING_DEPTH = 1; + + private static Object lock = new Object(); + + // Memo-ize factories so we don't have to recreate them. + private static Map factoryTable + = Collections.synchronizedMap(new HashMap()); + + /** + * Create thread to run a method. + * @param target execute this object's run() method + */ + public Thread(final Runnable target) { + super(new Runnable() { + public void run() { + ThreadState threadState = _threadState.get(); + threadState.reset(); + target.run(); + // collect statistics + synchronized (lock){ + totalCommitted += threadState.committed; + totalTotal += threadState.total; + totalCommittedMemRefs += threadState.committedMemRefs; + totalTotalMemRefs += threadState.totalMemRefs; + } + } + }); + } + /** + * no-arg constructor + */ + public Thread() { + super(); + } + + /** + * Establishes a contention manager. You must call this method + * before creating any Thread. + * + * @see dstm2.ContentionManager + * @param theClass class of desired contention manager. + */ + public static void setContentionManagerClass(Class theClass) { + Class cm; + try { + cm = Class.forName("dstm2.ContentionManager"); + } catch (ClassNotFoundException e) { + throw new PanicException(e); + } + try { + contentionManagerClass = theClass; + } catch (Exception e) { + throw new PanicException("The class " + theClass + + " does not implement dstm2.ContentionManager"); + } + } + + /** + * set Adapter class for this thread + * @param adapterClassName adapter class as string + */ + public static void setAdapterClass(String adapterClassName) { + try { + adapterClass = (Class)Class.forName(adapterClassName); + } catch (ClassNotFoundException ex) { + throw new PanicException("Adapter class not found: %s\n", adapterClassName); + } + } + + /** + * Tests whether the current transaction can still commit. Does not + * actually end the transaction (either commitTransaction or + * abortTransaction must still be called). The contention + * manager of the invoking thread is notified if the onValidate fails + * because a TMObject opened for reading was invalidated. + * + * @return whether the current transaction may commit successfully. + */ + static public boolean validate() { + ThreadState threadState = _threadState.get(); + return threadState.validate(); + } + + /** + * Gets the current transaction, if any, of the invoking Thread. + * + * @return the current thread's current transaction; null if + * there is no current transaction. + */ + static public Transaction getTransaction() { + return _threadState.get().transaction; + } + + /** + * Gets the contention manager of the invoking Thread. + * + * @return the invoking thread's contention manager + */ + static public ContentionManager getContentionManager() { + return _threadState.get().manager; + } + + /** + * Create a new factory instance. + * @param _class class to implement + * @return new factory + */ + static public Factory makeFactory(Class _class) { + try { + Factory factory = (Factory) factoryTable.get(_class); + + if (factory == null) { + factory = new AtomicFactory(_class, adapterClass); + factoryTable.put(_class, factory); + } + return factory; + } catch (Exception e) { + throw new PanicException(e); + } + } + + /** + * Execute a transaction + * @param xaction execute this object's call() method. + * @return result of call() method + */ + public static T doIt(Callable xaction) { + ThreadState threadState = _threadState.get(); + ContentionManager manager = threadState.manager; + T result = null; + boolean flag = false; + try { + while (true) { + threadState.beginTransaction(); + + /////For Integrating with IO////////// + Wrapper.Initialize(Thread.getTransaction()); + ////////////////////////////////////// + try { + result = xaction.call(); + + // } catch (AbortedException d) { + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " aborted in committing"); + }*/ + + // } //catch (SnapshotException s) { + //threadState.abortTransaction(); + //} + // catch (Exception e) { + // e.printStackTrace(); + // throw new PanicException("Unhandled exception " + e); + // } + threadState.totalMemRefs += threadState.transaction.memRefs; + threadState.transaction.attempts++; + /*synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " ghabl az try"); + }*/ + // try{ + + + // if (!flag) + Wrapper.prepareIOCommit(); + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() + " to try"); + }*/ + /////////////////////////////// + + if (threadState.commitTransaction()) { + threadState.committedMemRefs += threadState.transaction.memRefs; + + Wrapper.commitIO(); + flag = true; + } + } + catch(AbortedException ex){ + threadState.depth--; + /// synchronized(benchmark.lock){ + // System.out.println(Thread.currentThread() + " aborted in committing"); + //} + + } + catch (Exception e) { + e.printStackTrace(); + throw new PanicException("Unhandled exception " + e); + } + finally{ + + Wrapper.getTransaction().unlockAllLocks(); + if (flag == true) + break; + } + + // transaction aborted + } + if (threadState.transaction != null) { + threadState.abortTransaction(); + } + } finally { + threadState.transaction = null; + Wrapper.setTransaction(null); + } + // collect statistics + synchronized (lock){ + totalTotalMemRefs = threadState.totalMemRefs; + totalCommittedMemRefs = threadState.committedMemRefs; + totalCommitted += threadState.committed; + totalTotal += threadState.total; + threadState.reset(); // set up for next iteration + } + throw new GracefulException(); + } + /** + * Execute transaction + * @param xaction call this object's run() method + */ + public static void doIt(final Runnable xaction) { + doIt(new Callable() { + public Boolean call() { + xaction.run(); + return false; + }; + }); + } + + /** + * number of transactions committed by this thread + * @return number of transactions committed by this thread + */ + public static long getCommitted() { + return totalCommitted; + } + + /** + * umber of transactions aborted by this thread + * @return number of aborted transactions + */ + public static long getAborted() { + return totalTotal - totalCommitted; + } + + /** + * number of transactions executed by this thread + * @return number of transactions + */ + public static long getTotal() { + return totalTotal; + } + + /** + * Register a method to be called every time this thread validates any transaction. + * @param c abort if this object's call() method returns false + */ + public static void onValidate(Callable c) { + _threadState.get().onValidate.add(c); + } + /** + * Register a method to be called every time the current transaction is validated. + * @param c abort if this object's call() method returns false + */ + public static void onValidateOnce(Callable c) { + _threadState.get().onValidateOnce.add(c); + } + /** + * Register a method to be called every time this thread commits a transaction. + * @param r call this object's run() method + */ + public static void onCommit(Runnable r) { + _threadState.get().onCommit.add(r); + } + /** + * Register a method to be called once if the current transaction commits. + * @param r call this object's run() method + */ + public static void onCommitOnce(Runnable r) { + _threadState.get().onCommitOnce.add(r); + } + /** + * Register a method to be called every time this thread aborts a transaction. + * @param r call this objec't run() method + */ + public static void onAbort(Runnable r) { + _threadState.get().onAbort.add(r); + } + /** + * Register a method to be called once if the current transaction aborts. + * @param r call this object's run() method + */ + public static void onAbortOnce(Runnable r) { + _threadState.get().onAbortOnce.add(r); + } + /** + * get thread ID for debugging + * @return unique id + */ + public static int getID() { + return _threadState.get().hashCode(); + } + + /** + * reset thread statistics + */ + public static void clear() { + totalTotal = 0; + totalCommitted = 0; + totalCommittedMemRefs = 0; + totalTotalMemRefs = 0; + stop = false; + } + + /** + * Class that holds thread's actual state + */ + public static class ThreadState { + + int depth = 0; + ContentionManager manager; + + private long committed = 0; // number of committed transactions + private long total = 0; // total number of transactions + private long committedMemRefs = 0; // number of committed reads and writes + private long totalMemRefs = 0; // total number of reads and writes + + Set> onValidate = new HashSet>(); + Set onCommit = new HashSet(); + Set onAbort = new HashSet(); + Set> onValidateOnce = new HashSet>(); + Set onCommitOnce = new HashSet(); + Set onAbortOnce = new HashSet(); + + Transaction transaction = null; + + /** + * Creates new ThreadState + */ + public ThreadState() { + try { + manager = (ContentionManager)Thread.contentionManagerClass.newInstance(); + } catch (NullPointerException e) { + throw new PanicException("No default contention manager class set."); + } catch (Exception e) { // Some problem with instantiation + throw new PanicException(e); + } + } + + /** + * Resets any metering information (commits/aborts, etc). + */ + public void reset() { + committed = 0; // number of committed transactions + total = 0; // total number of transactions + committedMemRefs = 0; // number of committed reads and writes + totalMemRefs = 0; // total number of reads and writes + } + + /** + * used for debugging + * @return string representation of thread state + */ + public String toString() { + return + "Thread" + hashCode() + "["+ + "committed: " + committed + "," + + "aborted: " + ( total - committed) + + "]"; + } + + /** + * Can this transaction still commit? + * This method may be called at any time, not just at transaction end, + * so we do not clear the onValidateOnce table. + * @return true iff transaction might still commit + */ + public boolean validate() { + try { + // permanent + for (Callable v : onValidate) { + if (!v.call()) { + return false; + } + } + // temporary + for (Callable v : onValidateOnce) { + if (!v.call()) { + return false; + } + } + return transaction.validate(); + } catch (Exception ex) { + return false; + } + } + + /** + * Call methods registered to be called on commit. + */ + public void runCommitHandlers() { + try { + // permanent + for (Runnable r: onCommit) { + r.run(); + } + // temporary + for (Runnable r: onCommitOnce) { + r.run(); + } + onCommitOnce.clear(); + onValidateOnce.clear(); + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + /** + * Starts a new transaction. Cannot nest transactions deeper than + * Thread.MAX_NESTING_DEPTH. The contention manager of the + * invoking thread is notified when a transaction is begun. + */ + public void beginTransaction() { + transaction = new Transaction(); + if (depth == 0) { + total++; + } + // first thing to fix if we allow nested transactions + if (depth >= 1) { + throw new PanicException("beginTransaction: attempting to nest transactions too deeply."); + } + depth++; + } + + /** + * Attempts to commit the current transaction of the invoking + * Thread. Always succeeds for nested + * transactions. The contention manager of the invoking thread is + * notified of the result. If the transaction does not commit + * because a TMObject opened for reading was + * invalidated, the contention manager is also notified of the + * inonValidate. + * + * + * @return whether commit succeeded. + */ + public boolean commitTransaction() { + depth--; + if (depth < 0) { + throw new PanicException("commitTransaction invoked when no transaction active."); + } + if (depth > 0) { + throw new PanicException("commitTransaction invoked on nested transaction."); + } + if (depth == 0) { + if (validate() && transaction.commit()) { + committed++; + runCommitHandlers(); + return true; + } + abortTransaction(); + return false; + } else { + return true; + } + } + + /** + * Aborts the current transaction of the invoking Thread. + * Does not end transaction, but ensures it will never commit. + */ + public void abortTransaction() { + runAbortHandlers(); + transaction.abort(); + } + + /** + * Call methods registered to be called on commit. + */ + public void runAbortHandlers() { + try { + // permanent + for (Runnable r: onAbort) { + r.run(); + } + // temporary + for (Runnable r: onAbortOnce) { + r.run(); + } + onAbortOnce.clear(); + onValidateOnce.clear(); + } catch (Exception ex) { + throw new PanicException(ex); + } + } + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/Transaction.java b/Robust/Transactions/dstm2/src/dstm2/Transaction.java new file mode 100644 index 00000000..76205241 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/Transaction.java @@ -0,0 +1,291 @@ +/* + * Transaction.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import TransactionalIO.exceptions.PanicException; +import TransactionalIO.benchmarks.benchmark; +import TransactionalIO.interfaces.TransactionStatu; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; + +/** + * Transaction.java + * Keeps a transaction's status and contention manager. + */ + +public class Transaction implements TransactionStatu{ + + private TransactionStatu othersystem; + private boolean flag = true; + /** + * Possible transaction status + **/ + public enum Status {ABORTED, ACTIVE, COMMITTED}; + + /** + * Predefined committed transaction + */ + public static Transaction COMMITTED = new Transaction(Status.COMMITTED); + /** + * Predefined orted transaction + */ + public static Transaction ABORTED = new Transaction(Status.ABORTED); + + /** + * Is transaction waiting for another? + */ + public boolean waiting = false; + + /** + * Number of times this transaction tried + */ + public int attempts = 0; + + /** + * Number of unique memory references so far. + */ + public int memRefs = 0; + + /** + * Time in nanos when transaction started + */ + public long startTime = 0; + /** + * Time in nanos when transaction committed or aborted + */ + public long stopTime = 0; + + // generate unique ids + private static AtomicInteger unique = new AtomicInteger(100); + + /** Updater for status */ + private static final + AtomicReferenceFieldUpdater + statusUpdater = AtomicReferenceFieldUpdater.newUpdater + (Transaction.class, Status.class, "status"); + + private volatile Status status; + + private long id; + + private ContentionManager manager; + + /** + * Creates a new, active transaction. + */ + public Transaction() { + this.status = Status.ACTIVE; + this.id = this.startTime = System.nanoTime(); + this.manager = Thread.getContentionManager(); + } + + /** + * Creates a new transaction with given status. + * @param myStatus active, committed, or aborted + */ + private Transaction(Transaction.Status myStatus) { + this.status = myStatus; + this.startTime = 0; + } + + /** + * Access the transaction's current status. + * @return current transaction status + */ + public Status getStatus() { + return status; + } + + /** + * Tests whether transaction is active. + * @return whether transaction is active + */ + public boolean isActive() { + return this.getStatus() == Status.ACTIVE; + } + + /** + * Tests whether transaction is aborted. + * @return whether transaction is aborted + */ + public boolean isAborted() { + + return this.getStatus() == Status.ABORTED; + } + + /** + * Tests whether transaction is committed. + * @return whether transaction is committed + */ + public boolean isCommitted() { + return (this.getStatus() == Status.COMMITTED); + } + + /** + * Tests whether transaction is committed or active. + * @return whether transaction is committed or active + */ + public boolean validate() { + Status status = this.getStatus(); + switch (status) { + case COMMITTED: + throw new PanicException("committed transaction still running"); + case ACTIVE: + return true; + case ABORTED: + return false; + default: + throw new PanicException("unexpected transaction state: " + status); + } + } + + /** + * Tries to commit transaction + * @return whether transaction was committed + */ + public boolean commit() { + try { + while (this.getStatus() == Status.ACTIVE) { + if (statusUpdater.compareAndSet(this, + Status.ACTIVE, + Status.COMMITTED)) { + return true; + } + } + return false; + } finally { + wakeUp(); + } + } + + /** + * Tries to abort transaction + * @return whether transaction was aborted (not necessarily by this call) + */ + public boolean abort() { + try { + boolean flag = false; + while (this.getStatus() == Status.ACTIVE) { + if (statusUpdater.compareAndSet(this, Status.ACTIVE, Status.ABORTED)) { + flag = true; + // System.out.println(Thread.currentThread() +" tamam " + this.getStatus()); + } + } + if (flag) + if (getOtherSystem() != null && !(getOtherSystem().isAborted())){ + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" beeeeee gade sag raftim 1"); + } */ + getOtherSystem().abortThisSystem(); + /* synchronized(benchmark.lock){ + System.out.println(Thread.currentThread() +" beeeeeeeee gade sag raftim 2"); + } */ + } + + + + return this.getStatus() == Status.ABORTED; + } finally { + + wakeUp(); + } + } + + /** + * Returns a string representation of this transaction + * @return the string representcodes[ation + */ + public String toString() { + switch (this.status) { + case COMMITTED: + return "Transaction" + this.startTime + "[committed]"; + case ABORTED: + return "Transaction" + this.startTime + "[aborted]"; + case ACTIVE: + return "Transaction" + this.startTime + "[active]"; + default: + return "Transaction" + this.startTime + "[???]"; + } + } + + /** + * Block caller while transaction is active. + */ + public synchronized void waitWhileActive() { + while (this.getStatus() == Status.ACTIVE) { + try { + wait(); + } catch (InterruptedException ex) {} + } + } + /** + * Block caller while transaction is active. + */ + public synchronized void waitWhileActiveNotWaiting() { + while (getStatus() == Status.ACTIVE && !waiting) { + try { + wait(); + } catch (InterruptedException ex) {} + } + } + + /** + * Wake up any transactions waiting for this one to finish. + */ + public synchronized void wakeUp() { + notifyAll(); + } + + /** + * This transaction's contention manager + * @return the manager + */ + public ContentionManager getContentionManager() { + return manager; + } + + + + public TransactionStatu getOtherSystem() { + return othersystem; + } + + public void setOtherSystem(TransactionStatu othersystem) { + this.othersystem = othersystem; + } + + public void abortThisSystem() { + abort(); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/atomic.java b/Robust/Transactions/dstm2/src/dstm2/atomic.java new file mode 100644 index 00000000..bfa3b57e --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/atomic.java @@ -0,0 +1,47 @@ +/* + * atomic.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation indicating that class is atomic (can be shared among transactions). + * @author Maurice Herlihy + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface atomic { + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/exceptions/GracefulException.java b/Robust/Transactions/dstm2/src/dstm2/exceptions/GracefulException.java new file mode 100644 index 00000000..cb2e0082 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/exceptions/GracefulException.java @@ -0,0 +1,48 @@ +/* + * GracefulException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; + +/** + * Thrown by the BaseContentionManager when the benchmark time has elapsed. + **/ +public class GracefulException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new GracefulException instance with no detail message. + */ + public GracefulException() { + super(); + } + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/exceptions/MemoryAbortedException.java b/Robust/Transactions/dstm2/src/dstm2/exceptions/MemoryAbortedException.java new file mode 100644 index 00000000..d4b03ce3 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/exceptions/MemoryAbortedException.java @@ -0,0 +1,56 @@ +/* + * AbortedException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; +/** + * Thrown by an attempt to open a TMObject to indicate + * that the current transaction cannot commit. + **/ +public class MemoryAbortedException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new DeniedException instance with no detail message. + */ + public MemoryAbortedException() { + super(); + } + + + /** + * Creates a new Denied instance with the specified detail message. + * @param msg the detail message. + */ + public MemoryAbortedException(String msg) { + super(msg); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/exceptions/PanicException.java b/Robust/Transactions/dstm2/src/dstm2/exceptions/PanicException.java new file mode 100644 index 00000000..0325beab --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/exceptions/PanicException.java @@ -0,0 +1,69 @@ +/* + * PanicException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; + +/** + * Thrown to indicate an error in the use of the transactional memory; + * that is, a violation of the assumptions of use. + */ +public class PanicException extends java.lang.RuntimeException { + + /** + * Creates new PanicException with no detail message. + */ + public PanicException() { + } + + public PanicException(String format, Object ... args) { + super(String.format(format, args)); + } + + /** + * Creates a new PanicException with the specified detail message. + * + * @param msg the detail message. + */ + public PanicException(String msg) { + super(msg); + } + + /** + * Creates an PanicException with the specified cause. + * + * @param cause Throwable that caused PanicException to be thrown + */ + public PanicException(Throwable cause) { + super(cause); + } +} + diff --git a/Robust/Transactions/dstm2/src/dstm2/exceptions/SnapshotException.java b/Robust/Transactions/dstm2/src/dstm2/exceptions/SnapshotException.java new file mode 100644 index 00000000..dfcf079c --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/exceptions/SnapshotException.java @@ -0,0 +1,58 @@ +/* + * SnapshotException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; + +/** + * Thrown if shapshot validation fails. Will abort transaction if not + * caught by the application. + * + * @author Maurice Herlihy + */ +public class SnapshotException extends java.lang.RuntimeException { + + /** + * Creates a new SnapshotException instance with no detail message. + */ + public SnapshotException() { + super(); + } + + + /** + * Creates a new SnapshotException instance with the specified detail message. + * @param msg the detail message. + */ + public SnapshotException(String msg) { + super(msg); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Adapter.java b/Robust/Transactions/dstm2/src/dstm2/factory/Adapter.java new file mode 100644 index 00000000..52135902 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Adapter.java @@ -0,0 +1,77 @@ +/* + * Adapter.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +/** + * User-defined factories use this adapter interface. + * @author Maurice Herlihy + */ +public interface Adapter { + /** + * A Setter object represents void setMumble(V value) method. + **/ + public interface Setter { + /** + * Call setter. + */ + public void call(V x); + } + + /** + * A Getter object represents V getMumble() method. + **/ + public interface Getter { + /** + * Call getter. + */ + public V call(); + } + + /** + * creates a Setter + * @param methodName Name of setter, e.g., "setValue" + * @param _class field class, e.g., int.TYPE + * @return Setter object to call. + */ + public Setter makeSetter(String methodName, Class _class); + + /** + * creates a Getter + * @param methodName Name of getter, e.g., "getValue" + * @param _class field class, e.g., int.TYPE + * @return Getter object to call. + */ + public Getter makeGetter(String methodName, Class _class); + + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/AtomicFactory.java b/Robust/Transactions/dstm2/src/dstm2/factory/AtomicFactory.java new file mode 100644 index 00000000..1ee234f8 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/AtomicFactory.java @@ -0,0 +1,417 @@ +/* + * AtomicFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +/* + * AtomicFactory.java + * + * Created on November 16, 2005, 1:25 PM + * + * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries. + * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. + * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. + */ +import dstm2.ContentionManager; +import TransactionalIO.exceptions.AbortedException; +import TransactionalIO.exceptions.PanicException; +import dstm2.Transaction; +import dstm2.Transaction.Status; +import dstm2.factory.BaseFactory; +import dstm2.factory.ClassLoader; +import dstm2.factory.Copyable; +import dstm2.factory.Property; +import dstm2.factory.Releasable; +import dstm2.factory.Snapable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.*; +import org.apache.bcel.Repository; + +import static org.apache.bcel.Constants.*; +/** + * Factory for constructing atomic objects. + * User provides an Adapter class. + * @author Maurice Herlihy + */ +public class AtomicFactory extends dstm2.factory.BaseFactory { + + Class adapterClass; + + public AtomicFactory(Class _class, Class adapterClass) { + super(_class); + synchronized (lock) { // BCEL is not thread-safe! + + interfaceName = _class.getName(); + this.adapterClass = adapterClass; + className = _class.getName() + "$"; + Class[] interfaces = adapterClass.getInterfaces(); + String[] myInterfaces = new String[interfaces.length]; + myInterfaces[0] = _class.getName(); + int i = 1; + for (Class c : interfaces) { + if (!c.equals(dstm2.factory.Adapter.class)) { + myInterfaces[i++] = c.getName(); + } + } + + _cg = new ClassGen(className, + "java.lang.Object", + "Factory.java", + ACC_PUBLIC | ACC_SUPER, + myInterfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + + createFields(); + + createCtor(); + + for (Property p : properties) { + createGetMethod(p); + createSetMethod(p); + } + for (Class c : interfaces) { + if (!c.equals(dstm2.factory.Adapter.class)) { + JavaClass jc = null; + try { + jc = Repository.lookupClass(c); + + } catch (java.lang.ClassNotFoundException ex) { + throw new PanicException("Class not found: " + _class); + } + for (Method m : jc.getMethods()) { + passThrough(c, m); + } + } + } + createStatic(); + seal(); + } + } + + public T create() { + try { + synchronized(lock) { // not sure this is needed ... + return theClass.newInstance(); + } + } catch (InstantiationException ex) { + throw new PanicException(ex); + } catch (IllegalAccessException ex) { + throw new PanicException(ex); + } + } + + private String getFieldName(Property p) { + return p.getMethod.getName() + "$$"; + } + private String setFieldName(Property p) { + return p.setMethod.getName() + "$$"; + } + + private void createFields() { + FieldGen field; + // static Class _class; + field = new FieldGen(ACC_STATIC, new ObjectType("java.lang.Class"), "_class", _cp); + _cg.addField(field.getField()); + // Adapter adapter; + field = new FieldGen(0, new ObjectType(adapterClass.getName()), "adapter", _cp); + _cg.addField(field.getField()); + // getter and setter fields for each property + for (Property p : properties) { + field = new FieldGen(0, new ObjectType("dstm2.factory.Adapter$Getter"), getFieldName(p), _cp); + _cg.addField(field.getField()); + + field = new FieldGen(0, new ObjectType("dstm2.factory.Adapter$Setter"), setFieldName(p), _cp); + _cg.addField(field.getField()); + } + } + + private void initRegularField(Property p, InstructionList il, MethodGen method) { + + InstructionHandle ih_0 = il.append(new PUSH(_cp, p._class.getName())); + il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); + il.append(_factory.createStore(Type.OBJECT, 2)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.getMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeGetter", new ObjectType("dstm2.factory.Adapter$Getter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.PUTFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.setMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeSetter", new ObjectType("dstm2.factory.Adapter$Setter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_33 = il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.PUTFIELD)); + InstructionHandle ih_36; + BranchInstruction goto_36 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_36 = il.append(goto_36); + InstructionHandle ih_39 = il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createNew("dstm2.exceptions.PanicException")); + il.append(InstructionConstants.DUP); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.exceptions.PanicException", "", Type.VOID, new Type[] { new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL)); + il.append(InstructionConstants.ATHROW); + InstructionHandle ih_49 = il.append(InstructionConstants.NOP); + goto_36.setTarget(ih_49); + method.addExceptionHandler(ih_0, ih_33, ih_39, new ObjectType("java.lang.ClassNotFoundException")); + } + + private void initPrimitiveField(Property p, InstructionList il, MethodGen method) { + InstructionHandle ih_0 = il.append(new PUSH(_cp, p._class.getName())); + il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + pushPrimitiveClass(il, p._class); + il.append(_factory.createStore(Type.OBJECT, 2)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.getMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeGetter", new ObjectType("dstm2.factory.Adapter$Getter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.PUTFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.setMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeSetter", new ObjectType("dstm2.factory.Adapter$Setter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_33 = il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.PUTFIELD)); + InstructionHandle ih_36; + BranchInstruction goto_36 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_36 = il.append(goto_36); + InstructionHandle ih_39 = il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createNew("dstm2.exceptions.PanicException")); + il.append(InstructionConstants.DUP); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.exceptions.PanicException", "", Type.VOID, new Type[] { new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL)); + il.append(InstructionConstants.ATHROW); + InstructionHandle ih_49 = il.append(InstructionConstants.NOP); + goto_36.setTarget(ih_49); + method.addExceptionHandler(ih_0, ih_33, ih_39, new ObjectType("java.lang.ClassNotFoundException")); + } + // Create constructor + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createNew(adapterClass.getName())); + il.append(InstructionConstants.DUP); + il.append(_factory.createFieldAccess(className, "_class", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); + il.append(_factory.createInvoke(adapterClass.getName(), "", Type.VOID, new Type[] { new ObjectType("java.lang.Class") }, Constants.INVOKESPECIAL)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.PUTFIELD)); + + for (Property p : properties) { + if (p._class.isPrimitive()) { + initPrimitiveField(p, il, method); + } else { + initRegularField(p, il, method); + } + } + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createGetMethod(Property p) { + if (p._class.isPrimitive()) { + createPrimitiveGetMethod(p); + } else { + createRegularGetMethod(p); + } + } + private void createSetMethod(Property p) { + if (p._class.isPrimitive()) { + createPrimitiveSetMethod(p); + } else { + createRegularSetMethod(p); + } + } + + private void createStatic() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + InstructionHandle ih_0 = il.append(new PUSH(_cp, interfaceName)); + il.append(_factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); + InstructionHandle ih_5 = il.append(_factory.createFieldAccess(className, "_class", new ObjectType("java.lang.Class"), Constants.PUTSTATIC)); + InstructionHandle ih_8; + BranchInstruction goto_8 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_8 = il.append(goto_8); + InstructionHandle ih_11 = il.append(_factory.createStore(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.ClassNotFoundException", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_16 = il.append(_factory.createReturn(Type.VOID)); + goto_8.setTarget(ih_16); + method.addExceptionHandler(ih_0, ih_5, ih_11, new ObjectType("java.lang.ClassNotFoundException")); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void pushPrimitiveClass(InstructionList il, Class _class) { + il.append(_factory.createFieldAccess(unboxedClass(_class), "TYPE", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); + } + + private String unboxedClass(Class _class) { + if (_class.equals(Boolean.TYPE)) { + return "java.lang.Boolean"; + } else if (_class.equals(Character.TYPE)) { + return "java.lang.Character"; + } else if (_class.equals(Byte.TYPE)) { + return "java.lang.Byte"; + } else if (_class.equals(Short.TYPE)) { + return "java.lang.Short"; + } else if (_class.equals(Integer.TYPE)) { + return "java.lang.Integer"; + } else if (_class.equals(Long.TYPE)) { + return "java.lang.Long"; + } else if (_class.equals(Float.TYPE)) { + return "java.lang.Float"; + } else if (_class.equals(Double.TYPE)) { + return "java.lang.Double"; + } else { + throw new PanicException("Unrecognized primitive type: " + _class); + } + } + + private void createPrimitiveGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.GETFIELD)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Getter", "call", Type.OBJECT, Type.NO_ARGS, Constants.INVOKEINTERFACE)); + il.append(_factory.createCheckCast(new ObjectType(unboxedClass(p._class)))); + il.append(_factory.createInvoke(unboxedClass(p._class), p._class.getName() + "Value", p.type, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); + il.append(_factory.createReturn(Type.INT)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createPrimitiveSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "arg0" }, p.setMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.GETFIELD)); + il.append(_factory.createLoad(Type.INT, 1)); + il.append(_factory.createInvoke(unboxedClass(p._class), "valueOf", new ObjectType(unboxedClass(p._class)), new Type[] { p.type }, Constants.INVOKESTATIC)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Setter", "call", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createRegularGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.GETFIELD)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Getter", "call", Type.OBJECT, Type.NO_ARGS, Constants.INVOKEINTERFACE)); + il.append(_factory.createCheckCast(new ObjectType(p._class.getName()))); + il.append(_factory.createReturn(Type.OBJECT)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + + } + private void createRegularSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "arg0" }, p.setMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.GETFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Setter", "call", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void passThrough(Class c, Method m) { + InstructionList il = new InstructionList(); + Type[] argTypes = m.getArgumentTypes(); + String[] argNames = new String[m.getArgumentTypes().length]; + int argCount = argTypes.length; + for (int i = 0; i < argCount; i++) { + argNames[i] = "arg" + i; + } + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, + m.getReturnType(), + argTypes, argNames, + m.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType("dstm2.factory.Adapter"), Constants.GETFIELD)); + il.append(_factory.createCheckCast(new ObjectType(c.getName()))); + il.append(_factory.createStore(Type.OBJECT, argCount + 1)); + + il.append(_factory.createLoad(Type.OBJECT, argCount + 1)); + for (int i = 0; i < argCount; i++) { + il.append(_factory.createLoad(argTypes[i], i + 1)); + } + il.append(_factory.createInvoke(c.getName(), + m.getName(), + m.getReturnType(), + m.getArgumentTypes(), + Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(m.getReturnType())); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/BaseFactory.java b/Robust/Transactions/dstm2/src/dstm2/factory/BaseFactory.java new file mode 100644 index 00000000..9d5ef747 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/BaseFactory.java @@ -0,0 +1,309 @@ +/* + * BaseFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +import dstm2.atomic; +import java.util.Map; +import java.util.Map.Entry; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.io.IOException; +import java.io.ByteArrayOutputStream; + +import dstm2.Transaction; +import TransactionalIO.exceptions.PanicException; + +import org.apache.bcel.classfile.*; +import org.apache.bcel.generic.*; +import org.apache.bcel.util.*; +import org.apache.bcel.Constants; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Method; + +/** + * Provides utility methods for factories. + * @author Maurice Herlihy + */ +public abstract class BaseFactory implements Factory { + /** + * BCEL is not thread-safe + **/ + protected static Object lock = new Object(); + /** + * BCEL instruction factory. + */ + protected InstructionFactory _factory; + /** + * Constant pool for created class. + */ + protected ConstantPoolGen _cp; + /** + * Used to generate the class. + */ + protected ClassGen _cg; + /** + * The actual class we are building. + */ + protected Class theClass; + /** + * The name of the class we are building. + */ + protected String className; + /** + * Interface exported by created class. + */ + protected String interfaceName; + + /** + * Set of properties. + **/ + protected Set properties = new HashSet(); + /** + * Set of other methods. + **/ + protected Set methods = new HashSet(); + + /** + * set of interfaces satisfied by this class + */ + protected Set interfaces = new HashSet(); + + /** + * This constructor separates methods into properties and miscellaneous + * methods. For properties, it deduces type and name of properties, and + * stores them in the properties set. Other methods go into + * the methods field. + * @param interfaces additional interfaces satisfied by this class and understood by this factory. + * @param _class interface class + */ + public BaseFactory(Class _class) { + if (!_class.isInterface()) { + throw new PanicException("%s is not an interface", _class); + } + parseProperties(_class); + } + + /** + * Once methods and fields have been defined, this method turns the + * byte code into a Java class. + */ + protected void seal() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + _cg.getJavaClass().dump(out); + } catch (IOException ex) { + throw new PanicException(ex); + } + byte[] bytes = out.toByteArray(); + ClassLoader classLoader = new ClassLoader(bytes); + theClass = classLoader.make(); + } + + /** + * Create a new field. + * @param type BCEL type of field. + * @param name field name + */ + protected void createField(Type type, String name) { + FieldGen field = new FieldGen(0, type, name, _cp); + _cg.addField(field.getField()); + } + + /** + * Extracts properties from interface definition. Does rudimentary type + * and sanity checking + * @param _class class to inspect. + */ + private void parseProperties(Class _class) { + // Make sure implied field types are scalar or atomic. + // Enough to check return type of getField() methods. + for (java.lang.reflect.Method method : _class.getMethods()) { + if (method.getName().substring(0,3).equals("get")) { + if (!isAtomicOrScalar(method.getReturnType())) { + throw new PanicException("Method %s return type %s not scalar or atomic.", + method.getName(), method.getReturnType().getName()); + } + } + } + JavaClass jc = null; + try { + jc = Repository.lookupClass(_class); + } catch (java.lang.ClassNotFoundException ex) { + throw new PanicException("Class not found: " + _class); + } + properties = new HashSet(); + methods = new HashSet(); + Map fieldMap = new HashMap(); + for (Method m : jc.getMethods()) { + String methodName = m.getName(); + Class returnClass = null; // need both class & type + try { + returnClass = _class.getMethod(methodName).getReturnType(); + } catch (NoSuchMethodException e) {}; + Type[] parameterTypes = m.getArgumentTypes(); + // for get and set methods + String fieldName = unCapitalize(methodName.substring(3)); + // for boolean is method + String fieldNameBool = unCapitalize(methodName.substring(2)); + // get method? + if (methodName.substring(0,3).equals("get")) { + Property record = fieldMap.get(fieldName); + if (parameterTypes.length != 0) { + throw new PanicException("Class %s: method %s\n has bad signature\n", + jc.getClassName(), methodName); + } + Type returnType = m.getReturnType(); + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, returnType, fieldName); + properties.add(newRecord); + newRecord.getMethod = m; + fieldMap.put(fieldName, newRecord); + } else { // not first time + if (!record.type.equals(returnType)) { + throw new PanicException("Class %s: inconsistent definitions for field type %s: %s vs %s\n", + jc.getClassName(), fieldName, record.type, returnType); + } else if (record.getMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.getMethod = m; + } + // is method + } else if (methodName.substring(0,2).equals("is")) { + Property record = fieldMap.get(fieldNameBool); + if (parameterTypes.length != 0) { + throw new PanicException("Class %s: method %s\n has bad signature\n", + jc.getClassName(), methodName); + } + Type returnType = m.getReturnType(); + if (!returnType.equals(Type.BOOLEAN)) { + throw new PanicException("Class %s: method %s\n must have Boolean argument\n", + jc.getClassName(), methodName); + } + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, returnType, fieldNameBool); + properties.add(newRecord); + newRecord.getMethod = m; + fieldMap.put(fieldNameBool, newRecord); + } else { // not first time + if (!record.type.equals(returnType)) { + throw new PanicException("Class %s: inconsistent definitions for field type %s: %s vs %s\n", + jc.getClassName(), fieldNameBool, record.type, returnType); + } else if (record.getMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.getMethod = m; + } + } else if (methodName.substring(0,3).equals("set")) { + Property record = fieldMap.get(fieldName); + if (parameterTypes.length != 1) { + throw new PanicException("Class %s: method %s has bad signature\n", + jc.getClassName(), methodName); + } + Type argType = parameterTypes[0]; + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, argType, fieldName); + properties.add(newRecord); + newRecord.setMethod = m; + fieldMap.put(fieldName, newRecord); + } else { // not first time + if (!record.type.equals(argType)) { + throw new PanicException("Class %s: inconsistent definitions for field arg type %s: %s vs %s\n", + jc.getClassName(), fieldName, record.type, argType); + } else if (record.setMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.setMethod = m; + } + } else { + throw new PanicException("%s: not a get/set method\n", m.getName()); + } + } + for (Entry entry : fieldMap.entrySet()) { + if (entry.getValue().getMethod == null) { + throw new PanicException("Class %s: method get%s not defined\n", + jc.getClassName(), entry.getKey()); + } else if (entry.getValue().setMethod == null) { + throw new PanicException("Class %s: method set%s not defined\n", + jc.getClassName(), entry.getKey()); + } + } + } + + /** + * Did caller declare a void release() method? + * @return whether to provide a release() implementation. + */ + protected boolean releaseDefined() { + for (Method m : methods) { + if (m.getName().equals("release") && + m.getReturnType() == Type.NULL && + m.getArgumentTypes().length == 0) { + return true; + } + } + return false; + } + + /** + * Checks whether a field type is scalar or declared atomic. + * @param _class class to check + * @return whether field is legit type for an atomic object + */ + public boolean isAtomicOrScalar(Class _class) { + return _class.isPrimitive() || + _class.isEnum() || + _class.isAnnotationPresent(atomic.class) || + _class.equals(Boolean.class) || + _class.equals(Character.class) || + _class.equals(Byte.class) || + _class.equals(Short.class) || + _class.equals(Integer.class) || + _class.equals(Long.class) || + _class.equals(Float.class) || + _class.equals(Double.class) || + _class.equals(String.class); + } + + String unCapitalize(String s) { + StringBuffer sb = new StringBuffer(s); + sb.setCharAt(0, Character.toLowerCase(sb.charAt(0))); + return sb.toString(); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/ClassLoader.java b/Robust/Transactions/dstm2/src/dstm2/factory/ClassLoader.java new file mode 100644 index 00000000..238f7664 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/ClassLoader.java @@ -0,0 +1,56 @@ +/* + * ClassLoader.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +/** + * Simple classloader used to turn BCEL-generated classes into Java classes. + * @author Maurice Herlihy + */ + public class ClassLoader extends java.lang.ClassLoader { + /** + * Holds actual bytes. + */ + byte[] stream; + /** + * Create instance of class loader. + * @param bytes + */ + public ClassLoader(byte[] bytes) { + stream = bytes; + } + /** + * Transform byte code into a Java class. + */ + public Class make() { + return (Class)defineClass(null, stream, 0, stream.length); + } + } diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Copyable.java b/Robust/Transactions/dstm2/src/dstm2/factory/Copyable.java new file mode 100644 index 00000000..5d7c38ed --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Copyable.java @@ -0,0 +1,41 @@ +/* + * Copyable.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +/** + * @author Maurice Herlihy + * Class provides a copyFrom(...) method. + */ +public interface Copyable extends CopyableDef{ + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/CopyableDef.java b/Robust/Transactions/dstm2/src/dstm2/factory/CopyableDef.java new file mode 100644 index 00000000..e019e5bf --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/CopyableDef.java @@ -0,0 +1,40 @@ +/* + * CopyableDef.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +/** + * Fool the generics machinery into allowing a copyFrom(T) method. + * @author Maurice Herlihy + */ +public interface CopyableDef { + void copyFrom(T other); +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Factory.java b/Robust/Transactions/dstm2/src/dstm2/factory/Factory.java new file mode 100644 index 00000000..1394ec4c --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Factory.java @@ -0,0 +1,48 @@ +/* + * Factory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import dstm2.Transaction; + +/** + * Interface for all Factory classes. + * @author Maurice Herlihy + */ +public interface Factory { + /** + * Creates a new object via no-arg constructor. Return type may satisfy + * other, factory-specific interfaces. + * @return new object. + */ + T create(); + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Property.java b/Robust/Transactions/dstm2/src/dstm2/factory/Property.java new file mode 100644 index 00000000..c75acfbb --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Property.java @@ -0,0 +1,95 @@ +/* + * Property.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import TransactionalIO.exceptions.PanicException; +import dstm2.atomic; +import java.lang.annotation.Annotation; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Map; +import java.util.Set; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.BasicType; +import org.apache.bcel.generic.Type; + +/** + * A property is a private or protected field prop of type + * T with T getProp() and void setProp(T) methods. + * If T is Boolean, getter can be boolean isProp(). + */ +public class Property { + /** + * Java class of property + */ + public Class _class; + /** + * BCEL type of property + */ + public Type type; + /** + * Method that reads property value. + */ + public Method getMethod; + /** + * Method that sets property value. + */ + public Method setMethod; + /** + * Name of field associated with property. + */ + public String name; + /** + * Create a property + * @param _type property type + * @param _name property name + */ + Property(Class _class, Type _type, String _name) { + this._class = _class; + this.type = _type; + this.name = _name; + } + + + /** + * for debugging + * @return property description + */ + public String toString() { + return String.format("Property[%s %s]", type, name); + } + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Releasable.java b/Robust/Transactions/dstm2/src/dstm2/factory/Releasable.java new file mode 100644 index 00000000..69ec6360 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Releasable.java @@ -0,0 +1,45 @@ +/* + * Releasable.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +/** + * The void release() method forgets that the + * transaction ever read or modified this object. Use with care. + * @author Maurice Herlihy + */ +public interface Releasable { + /** + * Forget that the calling transaction ever saw this object. + */ + void release(); +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/SequentialFactory.java b/Robust/Transactions/dstm2/src/dstm2/factory/SequentialFactory.java new file mode 100644 index 00000000..94203ef8 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/SequentialFactory.java @@ -0,0 +1,140 @@ +/* + * SequentialFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import TransactionalIO.exceptions.PanicException; +import dstm2.Transaction; +import dstm2.factory.BaseFactory; +import dstm2.factory.ClassLoader; +import dstm2.factory.Property; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.*; + +/** + * Simple factory that implements properties declared in an interface. + * Ignores all non-property methods. + * @author Maurice Herlihy + */ +public class SequentialFactory extends BaseFactory { + + /** + * Creates a new instance of SequentialFactory + * @param _class Run-time class of interface being implemented. + */ + public SequentialFactory(Class _class) { + super(_class); + synchronized(lock) { + className = _class.getName() + "$"; + int constants = Constants.ACC_PUBLIC | Constants.ACC_SUPER; + String[] interfaces = new String[] {_class.getName()}; + _cg = new ClassGen(className, "java.lang.Object", null, constants, interfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + createCtor(); + for (Property p : properties) { + createField(p.type, p.name); + createGetMethod(p); + createSetMethod(p); + } + seal(); + } + } + + /** + * Create an object. + * @return the object. + */ + public T create() { + try { + synchronized (lock) { + return theClass.newInstance(); + } + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + /** + * Create constructor for new class. + */ + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + /** + * Create getter for property. + * @param p Property to implement. + */ + private void createGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + InstructionHandle ih_4 = il.append(_factory.createReturn(p.type)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + /** + * create setter for new class + * @param p Property to implement + */ + private void createSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "value" }, p.setMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(p.type, 1)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + InstructionHandle ih_5 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/factory/Snapable.java b/Robust/Transactions/dstm2/src/dstm2/factory/Snapable.java new file mode 100644 index 00000000..e757c2f3 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/factory/Snapable.java @@ -0,0 +1,58 @@ +/* + * Snapable.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import TransactionalIO.exceptions.SnapshotException; + +/** + * Interface for objects that support snapshots. {@link http://www.cs.brown.edu/people/mph/ColeH05/herlihy-snapshot-final.pdf } + * @author Maurice Herlihy + */ +public interface Snapable { + /** + * Return version that would have been returned by a read open. + * @return current version + */ + T snapshot(); + /** + * Check that version is still current. + * @param snap Earlier snapshot. + * @throws SnapshotException if snapshot not current. + */ + void validate(T snap) throws SnapshotException; + /** + * If snapshot is current, convert to write access. + * @param snap prior snapshot + * @throws SnapshotException if snapshot not current. + */ + void upgrade(T snap) throws SnapshotException; +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/AggressiveManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/AggressiveManager.java new file mode 100644 index 00000000..c199b5e3 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/AggressiveManager.java @@ -0,0 +1,58 @@ +/* + * AggressiveManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.util.Random; +import dstm2.ContentionManager; +import dstm2.Transaction; + +/** + * The Chuck Norris contention manager: always abort other transaction. + * @author Maurice Herlihy + */ +public class AggressiveManager extends BaseManager { + + public AggressiveManager() { + } + public void resolveConflict(Transaction me, Transaction other) { + other.abort(); + } + + public long getPriority() { + throw new UnsupportedOperationException(); + } + + public void setPriority(long value) { + throw new UnsupportedOperationException(); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/BackoffManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/BackoffManager.java new file mode 100644 index 00000000..30f175ba --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/BackoffManager.java @@ -0,0 +1,101 @@ +/* + * BackoffManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.util.Random; +import dstm2.ContentionManager; +import dstm2.Transaction; +import java.util.Collection; + +/** + * Contention manager employing simple exponential backoff. + * @author Maurice Herlihy + */ +public class BackoffManager extends BaseManager { + static final int MIN_LOG_BACKOFF = 4; + static final int MAX_LOG_BACKOFF = 26; + static final int MAX_RETRIES = 22; + + Random random; + + int currentAttempt = 0; + + public BackoffManager() { + random = new Random(); + } + public void openSucceeded() { + super.openSucceeded(); + currentAttempt = 0; + } + public void resolveConflict(Transaction me, Transaction other) { + if (currentAttempt <= MAX_RETRIES) { + if (!other.isActive()) { + return; + } + int logBackoff = currentAttempt - 2 + MIN_LOG_BACKOFF; + if (logBackoff > MAX_LOG_BACKOFF) { + logBackoff = MAX_LOG_BACKOFF; + } + int sleep = random.nextInt(1 << logBackoff); + try { + Thread.sleep(sleep/1000000, sleep % 1000000); + } catch (InterruptedException ex) { + } + currentAttempt++; + } else { + other.abort(); + currentAttempt = 0; + } + } + public void resolveConflict(Transaction me, Collection others) { + if (currentAttempt <= MAX_RETRIES) { + int logBackoff = currentAttempt - 2 + MIN_LOG_BACKOFF; + if (logBackoff > MAX_LOG_BACKOFF) { + logBackoff = MAX_LOG_BACKOFF; + } + int sleep = random.nextInt(1 << logBackoff); + try { + Thread.sleep(sleep/1000000, sleep % 1000000); + } catch (InterruptedException ex) { + } + currentAttempt++; + } else { + for (Transaction other : others) { + if (other.isActive() && other != me) { + other.abort(); + } + } + currentAttempt = 0; + } + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/BaseManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/BaseManager.java new file mode 100644 index 00000000..a2c6650a --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/BaseManager.java @@ -0,0 +1,83 @@ +/* + * BaseManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; +import dstm2.ContentionManager; +import dstm2.Transaction; +import java.util.Collection; + +/** + * + * @author mph + */ +public class BaseManager implements ContentionManager { + long priority; + + /** Creates a new instance of BaseManager */ + public BaseManager() { + priority = 0; + } + + public void resolveConflict(Transaction me, Transaction other) { + } + + public void resolveConflict(Transaction me, Collection other) { + } + + public long getPriority() { + return priority; + } + + public void setPriority(long value) { + priority = value; + } + + public void openSucceeded() { + } + + /** + * Local-spin sleep method -- more accurate than Thread.sleep() + * Difference discovered by V. Marathe. + */ + protected void sleep(int ns) { + long startTime = System.nanoTime(); + long stopTime = 0; + do { + stopTime = System.nanoTime(); + } while((stopTime - startTime) < ns); + } + + public void committed() { + } + + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/EruptionManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/EruptionManager.java new file mode 100644 index 00000000..0cc72402 --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/EruptionManager.java @@ -0,0 +1,101 @@ +/* + * EruptionManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.ContentionManager; +import dstm2.Transaction; + +/** + * Resolves conflicts by increasing pressure on the transactions that + * a blocked transaction is waiting on, eventually causing them to + * erupt through to completion. The way this works is that each time a + * block is successfully opened, the transaction gains one point of + * "momentum". When a transaction finds itself blocked by another of + * higher priority, it adds its momentum (priority) to the other + * transaction and then waits for the other transaction to complete. + * Like the Karma manager, Eruption will only wait around so long + * before clobbering the other transaction and going on anyway; the + * maximum wait is proportional to the square of the difference in + * priorities between the two transactions. Of course, at contention + * time, if the other transaction has a lower priority, we just erupt + * past it. + * + * The reasoning behind this management scheme is that if a particular + * transaction is blocking resources critical to many other + * transactions, it will gain all of their priority in addition to its + * own and thus be much more likely to finish quickly and get out of + * the way of all the others. + * + * Note that while a transaction is blocked, other transactions can + * pile up behind it and increase its priority enough to outweigh the + * transaction it's blocked behind. + * + * @author Bill Scherer + * + **/ + +public class EruptionManager extends BaseManager { + static final int SLEEP_PERIOD = 1000; + + /** Creates a new instance of EruptionManager */ + public EruptionManager() { + priority = 0; + } + + public void resolveConflict(Transaction me, Transaction other) { + long transferred = 0; + ContentionManager otherManager = other.getContentionManager(); + for (int attempts = 0; ; attempts++) { + long otherPriority = otherManager.getPriority(); + long delta = otherPriority - priority; + if (delta < 0 || attempts > delta * delta) { + transferred = 0; + other.abort(); + return; + } + // Unsafe increment, but too expensive to synchronize. + if (priority > transferred) { + otherManager.setPriority(otherPriority + priority - transferred); + transferred = priority; + } + if (attempts < delta) { + sleep(SLEEP_PERIOD); + } + } + } + + public void openSucceeded() { + priority++; + } + +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/GreedyManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/GreedyManager.java new file mode 100644 index 00000000..7d966abb --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/GreedyManager.java @@ -0,0 +1,68 @@ +/* + * GreedyManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.Transaction; + +/** + * Tries to keep a maximal independent set running. + * If prior transaction is + * waiting or lower priority, then abort it. + * otherwise, wait for it to commit, abort, or wait + * Complete description in + * Rachid Guerraoui, Maurice Herlihy, and Sebastian Pochon, Toward a Theory of Transactional Contention Management, + * Proceedings of the Twenty-Fourth Annual Symposium on Principles of Distributed Computing (PODC). + * Las Vegas, NV July 2005. + * @author Maurice Herlihy + */ +public class GreedyManager extends BaseManager { + public void resolveConflict(Transaction me, Transaction other) { + if (other.waiting || other.startTime < me.startTime) { + other.abort(); + } else { + me.waiting = true; // I'm waiting + other.waitWhileActiveNotWaiting(); + me.waiting = false; // I'm no longer waiting + } + } + /** + * Reset priority only on commit. On abort, restart with previous priority. + **/ + public void committed() { + setPriority(0); + } + + public void openSucceeded() { + setPriority(getPriority() + 1); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/KarmaManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/KarmaManager.java new file mode 100644 index 00000000..6d9737ed --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/KarmaManager.java @@ -0,0 +1,84 @@ +/* + * KarmaManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; +import dstm2.Transaction; +import dstm2.ContentionManager; + +/** + * Uses "karmic debt management" to resolve conflicts. Roughly, a + * thread gains "karma" for every object it successfully opens, and + * threads with greater karma can abort transactions of other threads. + * A thread's karma is reset every time it successfully commits a + * transaction, but not when it is aborted (hence the name). + * + * When conflict occurs between two transactions, the one with the + * greater accumulated karma wins. If the other transaction holds a + * block, it gets aborted immediately. Otherwise, the "lesser" + * transaction backs off for a fixed interval and up to the square of + * the difference in karma bethere the two. + * + * The key idea behind this policy is that it allows long transactions + * to eventually finish even if mixed with lots of competing shorter + * transactions. This happens because the longer transaction will + * accumulate more and more karma each time it gets aborted, so it + * will eventually reach "critical mass" and be able to bulldoze its + * way through to get its work done. + * + * @author Bill Scherer + **/ + +public class KarmaManager extends BaseManager { + static final int SLEEP_PERIOD = 1000; + + public void resolveConflict(Transaction me, Transaction other) { + ContentionManager otherManager = other.getContentionManager(); + for (int attempts = 0; ; attempts++) { + long delta = otherManager.getPriority() - priority; + if (attempts > delta) { + other.abort(); + } + } + } + + /** + * Reset priority only on commit. On abort, restart with previous priority. + * "Cosmic debt"?. More like cosmic credit. + **/ + public void committed() { + setPriority(0); + } + + public void openSucceeded() { + setPriority(getPriority() + 1); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/KindergartenManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/KindergartenManager.java new file mode 100644 index 00000000..a6bb9ece --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/KindergartenManager.java @@ -0,0 +1,82 @@ +/* + * KindergartenManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.Transaction; +import dstm2.ContentionManager; +import dstm2.util.Random; +import java.util.TreeSet; + +/** + * Transactions take turns playing with blocks. + * + * @author Bill Scherer + */ +public class KindergartenManager extends BaseManager { + static final int SLEEP_PERIOD = 1000; // was 100 + static final int MAX_RETRIES = 100; // was 10 + TreeSet otherChildren; + Random random; + + /** Creates new Kindergarten manager */ + public KindergartenManager() { + super(); + otherChildren = new TreeSet(); + otherChildren.add(this); + random = new Random(); + } + + public void resolveConflict(Transaction me, Transaction other) { + try { + KindergartenManager otherManager = + (KindergartenManager) other.getContentionManager(); + // first, check sharing records. + if (otherChildren.contains(otherManager)) { + otherChildren.remove(otherManager); + other.abort(); // My turn! My turn! + return; + } + for (int i = 0; i < MAX_RETRIES; i++) { + this.sleep(SLEEP_PERIOD); + if (!other.isActive()) { + return; + } + } + me.abort(); // give up + return; + } catch (ClassCastException e) { + other.abort(); // Oh, other not a Kindergartener. Kill it. + return; + } + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/manager/PriorityManager.java b/Robust/Transactions/dstm2/src/dstm2/manager/PriorityManager.java new file mode 100644 index 00000000..14e33f6b --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/manager/PriorityManager.java @@ -0,0 +1,61 @@ +/* + * PriorityManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.ContentionManager; +import dstm2.Transaction; + +/** + * Older transaction always wins. + * @author Maurice Herlihy + */ +public class PriorityManager extends BaseManager { + + public PriorityManager() { + } + public void resolveConflict(Transaction me, Transaction other) { + if (me.startTime <= other.startTime) { + other.abort(); + } else { + other.waitWhileActive(); + } + } + + public long getPriority() { + throw new UnsupportedOperationException(); + } + + public void setPriority(long value) { + throw new UnsupportedOperationException(); + } +} diff --git a/Robust/Transactions/dstm2/src/dstm2/util/Random.java b/Robust/Transactions/dstm2/src/dstm2/util/Random.java new file mode 100644 index 00000000..ad1b038e --- /dev/null +++ b/Robust/Transactions/dstm2/src/dstm2/util/Random.java @@ -0,0 +1,255 @@ +/* + * Random.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.util; + +import java.io.*; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Lightweight random number generator. Not thread-safe. Synchronization in the + * java.util.Randome can distort the performance of multithreaded benchmarks. + */ +public class Random extends java.util.Random { + + /** use serialVersionUID from JDK 1.1 for interoperability */ + static final long serialVersionUID = 3905348978240129619L; + + private long seed; + + private final static long multiplier = 0x5DEECE66DL; + private final static long addend = 0xBL; + private final static long mask = (1L << 48) - 1; + + /** + * Creates a new random number generator. This constructor sets + * the seed of the random number generator to a value very likely + * to be distinct from any other invocation of this constructor. + */ + public Random() { this(++seedUniquifier + System.nanoTime()); } + private static volatile long seedUniquifier = 8682522807148012L; + + /** + * Creates a new random number generator using a single + * long seed: + *
+   * public Random(long seed) { setSeed(seed); }
+ * Used by method next to hold + * the state of the pseudorandom number generator. + * + * @param seed the initial seed. + * @see java.util.Random#setSeed(long) + */ + public Random(long seed) { + this.seed = 0L; + setSeed(seed); + } + + /** + * Sets the seed of this random number generator using a single + * long seed. The general contract of setSeed + * is that it alters the state of this random number generator + * object so as to be in exactly the same state as if it had just + * been created with the argument seed as a seed. The method + * setSeed is implemented by class Random as follows: + *
+   * synchronized public void setSeed(long seed) {
+   *       this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
+   *       haveNextNextGaussian = false;
+   * }
+ * The implementation of setSeed by class Random + * happens to use only 48 bits of the given seed. In general, however, + * an overriding method may use all 64 bits of the long argument + * as a seed value. + * + * Note: Although the seed value is an AtomicLong, this method + * must still be synchronized to ensure correct semantics + * of haveNextNextGaussian. + * + * @param seed the initial seed. + */ + public void setSeed(long seed) { + seed = (seed ^ multiplier) & mask; + this.seed = seed; + haveNextNextGaussian = false; + } + + /** + * Generates the next pseudorandom number. Subclass should + * override this, as this is used by all other methods.

+ * The general contract of next is that it returns an + * int value and if the argument bits is between 1 + * and 32 (inclusive), then that many low-order bits of the + * returned value will be (approximately) independently chosen bit + * values, each of which is (approximately) equally likely to be + * 0 or 1. The method next is implemented + * by class Random as follows: + *

+   * synchronized protected int next(int bits) {
+   *       seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
+   *       return (int)(seed >>> (48 - bits));
+   * }
+ * This is a linear congruential pseudorandom number generator, as + * defined by D. H. Lehmer and described by Donald E. Knuth in The + * Art of Computer Programming, Volume 2: Seminumerical + * Algorithms, section 3.2.1. + * + * @param bits random bits + * @return the next pseudorandom value from this random number generator's sequence. + * @since JDK1.1 + */ + protected int next(int bits) { + seed = (seed * multiplier + addend) & mask; + return (int)(seed >>> (48 - bits)); + } + + private static final int BITS_PER_BYTE = 8; + private static final int BYTES_PER_INT = 4; + + private double nextNextGaussian; + private boolean haveNextNextGaussian = false; + + /** + * Returns the next pseudorandom, Gaussian ("normally") distributed + * double value with mean 0.0 and standard + * deviation 1.0 from this random number generator's sequence. + *

+ * The general contract of nextGaussian is that one + * double value, chosen from (approximately) the usual + * normal distribution with mean 0.0 and standard deviation + * 1.0, is pseudorandomly generated and returned. The method + * nextGaussian is implemented by class Random as follows: + *

+   * synchronized public double nextGaussian() {
+   *    if (haveNextNextGaussian) {
+   *            haveNextNextGaussian = false;
+   *            return nextNextGaussian;
+   *    } else {
+   *            double v1, v2, s;
+   *            do {
+   *                    v1 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
+   *                    v2 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
+   *                    s = v1 * v1 + v2 * v2;
+   *            } while (s >= 1 || s == 0);
+   *            double multiplier = Math.sqrt(-2 * Math.log(s)/s);
+   *            nextNextGaussian = v2 * multiplier;
+   *            haveNextNextGaussian = true;
+   *            return v1 * multiplier;
+   *    }
+   * }
+ * This uses the polar method of G. E. P. Box, M. E. Muller, and + * G. Marsaglia, as described by Donald E. Knuth in The Art of + * Computer Programming, Volume 2: Seminumerical Algorithms, + * section 3.4.1, subsection C, algorithm P. Note that it generates two + * independent values at the cost of only one call to Math.log + * and one call to Math.sqrt. + * + * @return the next pseudorandom, Gaussian ("normally") distributed + * double value with mean 0.0 and + * standard deviation 1.0 from this random number + * generator's sequence. + */ + public double nextGaussian() { + // See Knuth, ACP, Section 3.4.1 Algorithm C. + if (haveNextNextGaussian) { + haveNextNextGaussian = false; + return nextNextGaussian; + } else { + double v1, v2, s; + do { + v1 = 2 * nextDouble() - 1; // between -1 and 1 + v2 = 2 * nextDouble() - 1; // between -1 and 1 + s = v1 * v1 + v2 * v2; + } while (s >= 1 || s == 0); + double multiplier = Math.sqrt(-2 * Math.log(s)/s); + nextNextGaussian = v2 * multiplier; + haveNextNextGaussian = true; + return v1 * multiplier; + } + } + + /** + * Serializable fields for Random. + * + * @serialField seed long; + * seed for random computations + * @serialField nextNextGaussian double; + * next Gaussian to be returned + * @serialField haveNextNextGaussian boolean + * nextNextGaussian is valid + */ + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("seed", Long.TYPE), + new ObjectStreamField("nextNextGaussian", Double.TYPE), + new ObjectStreamField("haveNextNextGaussian", Boolean.TYPE) + }; + + /** + * Reconstitute the Random instance from a stream (that is, + * deserialize it). The seed is read in as long for + * historical reasons, but it is converted to an AtomicLong. + */ + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + + ObjectInputStream.GetField fields = s.readFields(); + long seedVal; + + seedVal = (long) fields.get("seed", -1L); + if (seedVal < 0) + throw new java.io.StreamCorruptedException( + "Random: invalid seed"); + seed = seedVal; + nextNextGaussian = fields.get("nextNextGaussian", 0.0); + haveNextNextGaussian = fields.get("haveNextNextGaussian", false); + } + + + /** + * Save the Random instance to a stream. + * The seed of a Random is serialized as a long for + * historical reasons. + * + */ + synchronized private void writeObject(ObjectOutputStream s) throws IOException { + // set the values of the Serializable fields + ObjectOutputStream.PutField fields = s.putFields(); + fields.put("seed", seed); + fields.put("nextNextGaussian", nextNextGaussian); + fields.put("haveNextNextGaussian", haveNextNextGaussian); + + // save them + s.writeFields(); + + } + +} diff --git a/Robust/Transactions/libkooni.so b/Robust/Transactions/libkooni.so new file mode 100755 index 0000000000000000000000000000000000000000..c39b49a42fca85cdff153737f61f6dc6e1ecf0b4 GIT binary patch literal 26643 zcmchA4SZC^x&E269|^J(fg}n@H5fqrAmOWuR*^sgVi8dg@pIiIn`C3y#oY~pS_Oj^ z4D_PV{ymQXkv&(Ah?|*;) z11D#md7qhg=AC!u%$eCedq=~JsY)r!Jpxw1BH9+Ttns+6y~aq!TUA!j8fgu)hKk(f z^SZm#oFRgKmdGV;AmVXGkYNSRup_r|J%BU^Amh0cm?z~>YhCuIY%?y$9IiY7$?-TN zIQ!s~d~x+3ROK?37C+n$klFK;qnAdWvN?Fg6 z>Xl2LeC@v5rZoKK;NF|&4S8bK+huS3`fp`pF88o%pAu(I0xW-k^n~vC$S@D zlvRcEOa`2z3fIF<*yRs#@H@DkigP*6!6@u;$Y=mcc_Hv^sN{pV5~Bvzfk6N``dM%H zYT$i7%=YkOG@CVy#>X)LRy_gN4Kx^z0kHHoT!+CRbQR`rMWe0rQ^{y18%t-SQ7f8A zCbCwv1s8~#7R4BhbtGVTXxYdzpY^uqmYR*PQ7oq;BcDy;3jR7`hGR7i^N;X^5W=x+v zB|5fdOwG7l*b9xOZEf*B`d|<~QTQ)leE<&IhDYX<1l&Dn4M!U=u74r{*9=%=9NbT^ zZG8@y$6mBIn{XqpVL16FUeU&zd4=!nz_kS2oxH;Nckv3|ZeHO_dw2!!iWPsF-E}b7 z!#uB9x_x=2Wp%GP+}qoG*9+ND&qT!b&@FqakoUZ6e!ji;hjgUghaLAph&{Cpr}g@N zB

crEjD7_1%Iih#C3%Ho+JatTz66eUo5%e_IvtdSG0=17({#yXX7BOSiv;Y`PBi zTk@k}6n9?N-E|b~yS8P^y1S|nvm!XGhxv7Pj|5uPH4NcZYpU?~^xZ!`Vy{}zd+ytr zs#T9eXsxPKE4oPQUE4*5NptSo=|BIhi`lEL9sRDk{<`h7O-~IXmTpgp`e65(k>JBL zmECKOm{8wUU5tbN-WR%d1h2Vnd-srG+gCH~(u2#8xaT0mOSg|g4&4o<-B$PNN6;S6 z)(@kN5Y=x*{jeY;lEaFI!>bxro0!9_QyaKcWBY9~-zTFKy-B%o3x`PEm5l!iW@Qpk z-LTI!+pXv~Vz$FwJL+M8)wzRS(RC2kj`U1`ahGmi+#ik_9L9Sn?T@lDm!48&(X}Iz zpBUL7J^Jg1kS^Um5lOqd*j`;ndb5L8{gA;`n@7;+yWR@+?(Pml(0SPHXTC8gh@?Fh za=8lQ&2+1!nQ3?+2N@sSE920LGLCW-;ysS{bKct!v^L{>=cC>fo0@Zk31|rndDcb1 zoFg>g$~gcBC)RNb#zass6T+MZC(2=+i1R3f4DZ90_xCEC=r1zLcQB$p^}%_Qd$gk>x8S@7=T~ul7bnMlYuc14=T(iIHuH+ptH#%itr=G}vOeCJ zh$RggHSTnm;zf_E88d1u*$Dhg!vELIKQTS3FbpT{ZCcB;->E=sKibzlc!#j9Rrrg_ zG5vR%Lm9dufU!$#0m?`*X2(gZTK2g(1RZP) z0&KV8Xp_59K>I1Qko_XszzPIQZozauph{8fX$A{aUuT0+4RdlH^V0$*liIB0J{!2^#F*bgzc?=V;re4j~F_)3)4 z{we+h&*Y;~X>cvVl$8XB0QX_g-bHzW({1|{)HQU;48|V9*cF;No59yH7Yto`HG@Y` zpwO%sgKshRGU2{mg5c$xp4m^J@S)j@ky#)Zd=kL^1;(GyoNmUH27d`)e;x%5T``#o zFGYUg_&%oGftrL{zRuWRGT17?SU&{YB=`<&9!^N`RkT~UU4m1gJA9)ACn4W(hXhYT z;llGJcpAA$364ee!YK)U$lwAAHlzOGnIEc83}eVxabnJW=U{1{vP*p zw8XUt^krauAiU`NC}rdWmhab6muf2#LW_s@7!-^gPxKpuN+W}aUNk5Y`5)XZ!h6p_ zoL${7@^7rq?>YokM3%BZ`@Se>VB|kxobbyJ2^tbPpSFADDM3|{n^?&GuL>F#xelcZ zzxJV^k&(-2&jX)9mF?=YBKxV~&yxj>j=V|@uU{uTdIO=Y#51cG=}zVvQoj-DZMp@842RV_fPv~IN>4{1T%rc!IV4cMOzB0e z^l|EQf|n~jlezU(Hwa#-^l8Le-6eRn(x0dA9j_i0yjJP&(?$BLUkbio>8pv$)gi&_ zltywZT&eownK)3rUg<~ankT5U1wW#6ig=*9M(_rux3PSK)op?|D*f;1wBeJ~HwAA} zI!62%^)tbnkw5vTsJ{r_qI4NXop6Pt1M({SJ*Q2|JhpEd2?@;<) z;^FFM!8?_Hk1lbVS|@my(jTz_PghR~-mUbP*}P|{R|W4;dJgefssvMtK=odwn~7`G zNWuG*exJ=zt1c0|U+L$G$EdX614?hAea5LZf_sz>u?vh>TLd3e`e&@~+3F?1hm`&+ z(@#+E3qGv$uW0Xc)k&DL1geiH{dMBcsq+ONReC=0MAayGiLFc60Vb)Hf|uF)2ej8@ z^|;{WwmysYs8?Lx2vo1M^?v%#R23dfyxP_e5nrT63tnsMD_P!))m*{%+j;GnZ%~HDsKVs_<>{yqp_XTgT^?S7695w7D>f31Rmzn=ub+O=0 zwtkM~ou{&bH{1GV;;Yqzg16YZo89PIwL|b$Tfe~iT(8~|yv^3-#5bscLzw>#TWglD zQB4%Q)7C54ADUI0;9a)vPu!yJ6TI8j9qbQnYK!1Kum}C6UA-!JudOr09V+q}=D*L@ z%h+B?HCFI`Ti?gge}TGI@Bv$&L!4H33+}P?(`=ut+93F#t*@ZH7OLk3AF_2V@gj9t z@L^kXf*rn94LX_nj@WuH>vOw0SMX6=Kgyxw4t15_B>~;e_F1A93tkq`T-yjQRSyVW z9?;LQeeYCH2woY`akfvF`kmm_0ll35v`qa&@Y;aR(B5~cL8nmv{Q-S5^S@i2D|lT% zU%>WRuC5lmKA>M9{~mR#;70;_IQ6Ym>jZBI=r6LpzoecLyfL8PV|`Yumj!PM=o?ty z`&6&s%>jKK^{rJ^Rn)&FpxR&H|YoK~pK(8ZyNJiH{_3nV~$MN71)g}4u3Fu1N<59Ii@ZNxajQMR) z&k5ca(3i1(-&Jo3-XG9|I38_OA12tb{zKg^ z_)tLKN4!}*EckFhXIY-d)egZ&U|;s1E$Vf_M+3T>`kz!~r&8aNpx#aY+^T8?FAM50 z`A@4kf|m#N4{6VBYO&yzL0wJ%`HA|f;MGB0sepH=X9TYe>K|LcKT`(;-yhV!CElq* z)zr5xsC(GnzfflgULVvyBHpDg75qq0&tmzXR|^Dh2UB*2NA-Z<-9dd4{pVHngy20v{S)T*n);pKy+Qpo_TK~Q zAARiDGg8D@ISC6_{a8FQAr+wZ~w+cQO)OWId4ytv6 z4+Zt(EZ`hpElDdAE;G=SBCUiEZNn|B!yl2DWUIetk&K3j-^AxX2#~>2I(-ZM#nJhLFCT_6pe73f>sf)g{0|d#T_} zA-#wCLiRTWZw~1bn19&*iQp|E{TTUu?3V;@4e42wA7>vCye*_#S^mCu`AC*;M@Y}6 zJtB6E;GH2|%lx%HUGT1uoW(*!RI>u>b| zKHa`Z@ba*JnErRBoe;b-tlwmLN7?rXULDq3X^&d_dxF=7^=#UEjJ-?n{bBt>^2ghM z7rZX4UnKu*d*GSWzdo$%sBeNjQSc*S-NXKLp4}{XLs(B_d!29JBY0z2KSTaRdz0Wz zVZDL*O|oAUyg96wGyP=ysNgMO{W|T_V2?VB`nHC31@T4pY{A>Y`mX`t&)bUy?+EKJ zQQu7ayMlLy^)CARW%eHg?+WWP>5p^l$SCHwJFLgio>$rz2;LLcYx)9TZ6^iq4eP0F zzw7M>1@8-ME^LQm_7j5lhxOgZ0XN!v1Rn_NnH;~G9NZJu;RtZE{ej32qCWJGR(og- z^&blBk68YMJx%c8u>K0$zr$`7d?c&`)StAM3qFeSGyP4r>90#l^k~X6w&}0SO7u4B zUuZup{N*M30{ZXG_LG8FmgvXne~azif>)R5_t@UI*@pzLEz#>}-!IsGYgxYgOLT_m zZ?{JXURPq-eORHzThI+kf=}b`ahJgY9Hq+`s0uHhff8tW(!_HiYGYShS{^l(1A|(g zHEjo$>d&!E!SMOeVOK}=A6bP^xKUs~J(eX5JJJe0kp?OW-zn08`Z3zC)FBVC?2+`Z z6;~pQlHhgtd;DpLQ1+X2i+hq1on`bvM5ulrm0`&t{M25=^uGo7&3W*K{*6}nnX?#Z zvclV%7|2-RAD_cO0{2d?3iNNc!rL!lpapl&Bm>P>_@_%4=&-^+<3qV+GxzYbw;=NY zk?=21Ku?Zr;+W!3(@Zd}fynB@skv5j8<0AK;BhYElwh zB_cL0pXT#K8$?7NAMK5ZWvXCC6|^X_-Yz6Y^NBx4f~ZGCxM<)@Pg5cPCXtiOWdxBUwhQ4(#l-_R<^hS}0)olI zN&Y=VmV#&EEU__2RUqVEs;yOZJ^btuxTX0b!Cz2LLj>jX`*n&$5 zM(&u24-!Vixo=J+&2R$JUhEOL(ojIC7;1`qqeuGpA|%Ekr~kyI5Bp3>aJBGR1TIkI z3JejS{L2;V!o`Z5$Zgj@h@4Ks#S33~#DyK}ejp?ojVl_yOqhHkUXG2yU(F zJQCME3Q10_T7<;%axtWUL{;4$fvY101XtBYkHjUDLXxBES3;682J0LJB&vGXBXD7* zfZ(b+5u$R%T)5g&NODx2FC>m)T!JYeQB}+%a80Iw;HtXQBXOaokmRWPwvaeZa`mQw zL{+;y0+(|N2(GF(JrdV=3Q3Nt0T7u^$AzB)5>=h!5x5dmKyX#f^GIACDkM3oz91xy z^;|P5AW_vr9)XKU1q4^sc8|oBr9zUUsz*q?n{c_QfJ9Xq(dCK+u0ItJTvat5iHlN& zBuCY3A@P32m8t>~RW0%eT)HYCxT+rTNL{hNw~&xC#hV^O^{`+EpNQRag*J z%JNqs!O4Co2xb7_nwXEoLCG8ZCVMQdloeyS3fnv;*U*YG9nJR%lLH1<*NQP&!>t~R zYi`9@uI5)gCRgK%G9Aqk$W71ZI$bd)HJ|OVxO!KNBEXs5=TacG4jxJm~EXJhfGdvbo6pOK3&9giv*BXm59nH50 zllOG4LKb6E^CKRMYm>!TuI68OOs-lMWjdM<3zK6H*E5STsrh8c$`x5$HP?Gg zu74I~I+~Nh)_m>ik7##)R?%>y7SS7dSJ zwHV9QJi%jfO|~f0(cB1mrL5EzV^Ql$VQ}rX7{k^0n6S8_Ta@K!+XH#I;v9Am)?N)$ zhAjW|=Y1h@`g5*FBC23I6zCMhnmN{0MdcTYoKu9wMdeYEvpYXfRDOrZ+3B7rD*uMa z*)@JwRQ`;}>6-s2Dt|@fbTckE`^@FkuUF)3W-dS{w%S9ql7ijW+~eoRQT-do3# z*o%Jc5x8n@Y~q#0Rdv`SaVfo!P#{TdQAqBrf0=BXqRs4=%lridSJh`d z64(9x}2!}E;bj{hQ;@xQ426vSfuKUU_A|3cvIi?0coxw~+5 zgAlkKQ%G>fe<5&xrjX!{|3ct~O(DS@|AoLEoI-*-{tJOyI)wyx{D%nRe-VN^{tJPd zK7~2B<3B{@>WAnOcX}iVISYi#5!;6qDhaj;mGRu~%o z44_hWkaCGDm8hH~AcQAnIwaU;r*n54on&leF}skkXsAagVLwq(G~EACX~w4lm6 zMf3)8i~RTa%hSkNRaeeVgn>|4*6DBooQB0( zyDZ~)e-_pVFnAgk4dAlaol1fc$S`llU!I0VTevLtsgmGWVWshxr(w}7E{h!t{wl2d z@t3Dz(LyeZy{ja6yRe?dU!I0VW4SDLF+Bf4R;jp8XBeK9Dx6;a3n6gh&Je^*Vl{{G zS0QjG&k)2yVlamgfv8e(YtInGIASY@FiHsA>oWwgiPx6?YsBOU#mE(Ll(nURd0RG%T@Ajzueh)h;aVP8yaND956yz*;RV z?pYd^SSiP%y}){0Slr1pEHPD%MWcbWPgtj7f6}lD>_q`sBXQ|thF2TGO2rLOlc2zK z-1b3&al+!Zs9_bD&KZuc64p07R)Og#KwjU%rH|=-cSwTWUV;KEQh)?6G6DSoOF@!A zVf)jRqrjjPfK`G^AJZrQC<(@T2?}gW0TN7L0@FPQAXurIyaWYirT_^NOkjHI6a>xm zd5xDyo<9USZu|iG+_EbPW<5T4eN8pUhv*Sc#0_90;#~xyXFSp0JP|_>y@N|hke|pc z3H~18O2zG9lbUy0x$Brej*BbED-}11i?R+QTjX^b;gB6m(4PD2oWO+a#7Lxvy*zh#qG?^PSJdD`-XNI?Ic_){U)@5VMDz7i^e%EN&c2TElXhyA84S zSIR)0w-pJ>{-UulTzbn^L`RNd532OmUm+S>*^w_}@>qJ?vx0(F8SOBy&sqF(MC2JH z>NDyVhxpkDQ0+uPrIDq`q|ex|35rDCgJbnM=TSlZBEKyGn(zZb6_L^q&;@r18W`y< z1)8{8(2&Trlub4osv_r8L%q>3GI9X7q(0MFdVYlZ&EtSR|FWRbk!x}7bII$1#z*F2 zcd5_3HLP;=gvgnwL7%G(n#7f5tIyR2T@-np8rmBq-K@w>%=1Qr=2$1Hivrj~H!F|) zssg`)%Y)zT7#L43wA27@SKIem15=IdKy(QE-r%4OAgTfMbo<`Y!5k4(1uY%8cljNI z`=Y|Ck`7?sd&5bYY}!&M(!cF{JD~Cs7 zCE`#Cm4g&gcqBbfD#;4+DFh$LzCJkSb?(h`hKqObZo~5hFN|4 zPJ|rgcY=?utHh3Yulz~7QgMCI=yc{+q7EomIZ1h?IxRB2oSG^^Qjki<5TAfe zH|xY2bz#I*lRVaaQkc?#AumfC1;GbgU1Jaq9-jwK0(A6KIz%a>@-suBvKEFpxtJO; zdtpP|iCEj3NtybfOye)V@MGarpVnP0%lU2=Gq6H7zvvh!Q$uTqUU2o$*4EluJH#*V zhiraxE-=y&*!U8L8ipjc^}C{_=**;R@$IkL)~2S~#CZ8CSh91`sMcg>t$azaHj!-V z=xmN#wPZS=wlR^-eQ&Tsa@`CN?7*~I)fB2j&QHy&i;+vM1}%w61_BbKenB zOvZth{^rW+kuDnTjNa54YmR2EDY1@@$&0h`OXAtKR5Pp@MN7@MX2x%>PjxnS#Ou=O z*kY@_*$1Y@vkkZj;^Lz;bj0V!lW+*+(Abe`x-nx-#p@C}8q(=h+M1KPJl@g~Z_37- z9Yq(5cOu^l32I4hl)pWrJWMC}y3i6PMx>ySbkT~2D2dNvw9(KI8KY&DT} zLNl>bJ5sT%!)-}4k3)@H6Rhs+cvfUn6Y-8_YkFpOY<}EPUo6kLtj>HI#7!s#oFwp%v5q=BAxAwb>!8~$zpakok+G`F=y(O zwpbeGOsD1-T9M8#Ir%DF$HtqHg5AItp|5nTq>sz`#j>55Xk%v!t7r=7FSpgOs42dH zZ||s&XPVN9#yHz)dNS)b1QdGprFeEH-sRE6w}8O#&GChfpXI9SD?%Oh&TdPk^KxW4 zi_+&x{;p+a#FMSrHeW-aU{156;WF}KlJ@!H+SBWW<`L?c5iM(6Azz`7l`oi_N}+j^ zj*gH2vhJt+)-aWLI_KsW)T+y7V@+*SI@4)%usLn~s&HMVJ{HHDS=^2(DRTDmWd-B1 zlK$3W1GxtDd2%kfzfXB&uQRf_r0YqexgDu4lS#BDV;C{$r_xAXn|fV<)if^V7%<HawX|g7rb0O{%PW?Y zQ*`Ev*Z!$iXOX<&5+T3SOH2X1q z&}vV~earZTW7lGLM9=9iZE9jCZnn^gQ#Zq_td`^~JO|dt@fxMLxh;qZ-5Z;+Fh^H2 z>=;$~oyIq~!}XFKiR6v`+pWn$oKbG-i8OAtbjHb@EiLi1l}N%u$xgY!d1JWKTiO$@ z*XOIu`LeNL{-6l|pm#go5f^11F!u4F+z0ae0Sr)Y3MmDwYi`CixfpXm=M~9Ib-PsN7#hWZddtH>?0$6Q!y^#l$X=wU!s&osvv}4* zYdd!hj0bRclciJN;!CoAH~u)BG}f;!jkUZS}cW_2yDA9)_*83vVcZeuK?@t*vyjI44# zAB`@EHIIP}aT!ayc{%!elBt6+7df7_d>r2pZ5o$1a1t|4Kl3K9C}FN~9Gf`poQwC@ zr*H&w{cb!J&5frs?zEj{cS@PxKt4fJM`kSB#jB@N0%T>3C1o&u1#vPM_$H*Rk?S}4 zI&$NuGehBc?>eNHJJaVnVlFp%CgBW&nfmQ5nfW^~ACfZ*;!Vz=CW8(~lU%O;w5@f#}ALS2}Kv2&tOq|iqulmQX3gveYf7bp-fxOYl|Gb}@1l4`Q8jl;=KM5si#;-0?KdNdg~?Pry)fQ9+6#^GLSwzqIG^kIMnuOcozmnx zCdy>$X32wK7Cj)>_PJW-tn6=O-#AEbGzOt-`n#3a*>ZzM@!Xs>0*(}kyJrYAGmSh6X8X$$+Ae_HE}3%MHj z2C71*aZ2fScH|{wVc>^mm&5eM0sX2KwMm4n&{d8rg(9B!r#6AuA+4+4FY?IDe zUCAlUvF2J=B-75DVNJ)EMMBKP#3;FiMd$V!H4ibSeN0(A9cJVb=gi#@3&tg%z%`Uq z)yW>+jJ?cp<&Rl#MB5wpG$wY)X13-ngfK(C?$%c+xSXtg95ZZt6E(-oT+!vKux(}K zMQvEpX1J7BuJYPeCzgiILHrGzK#70Rg+mfKO1YrHJdiqHaCRDiJG=prp>BpUYrEY zT=BG9L&-vCF6IYO$kOo+@=ahtN7ky5R}R-?{?tfrCMDkBYt=NR=5xgw)OcfOYcz)U6t`mk(t!&)8@ck} z;Y6|}<;r4>jcLrk944N)<8Ig~kI501aN|2tD2a)6)X?nz(t(fATinj$2FGUSoP{er zg$J5NPJE-rdKd4SB#$n|vmW6>-f+ZW`%3b=2ppb=m&ddf9 zoWl)%7MSn6q+Y)7lIO_?yLuVVb23i8Ba>miCzIzSg#CH}t;=xs!AageaClZBjEfxP z(*?N=>++65$a5s($is%6thpW^4-G8>JsdoVv9*W+|~^mU#$P~aTo@l4=! zdD{@dvxiEZgSO+5!s+tZuXqj-iTT64cy!_q@Q56XCa0jJB`1rAR)56a!} z7abmp#P_oE9qst<9WL)nh+%%@?FDb|$MC-Fg7ADH=+@-{p%g%@!WvZTosnbH76->P9s$QwId&P$T9`4)V2*fZ zEHaoQycu&0Ha*O}cL(I{$Yu;Na(oB`2geH@0r}+xGcFiR%c1Xka<+=;=e!2wC9mkq z=vM~g;}$sBZ+QgdEy~Ex!^Uyg4~-n(jrSb^dE0U>BDd3R;sX5gwC@O5gMEnlcsI-) zfxMBIa(w;JcLd~)m5T^iyzAzUfK}!B8DoR^t%dwC>+N2A#oe=?g8haAb6n-2;CbxI zuKg6=B0ULso70{)?#Oe2X%D)P!W$sqmezh?QiwCSPBLx-Z|hqyX1?8f2jqJ^eaBlX zfq9SMq3|miU&Yn0|54xtj-2^9u1mVqkK>?wu)fa&xb3Ozw|fr&k4AcYzRR-hzSdt0 zFvlsky_H>QeF(hIEuY;_e$(P+w?0Te6a{eKcg_6Ia0+w}(&58))&&mceU*5oufSEn z*A?KKfO*g5!QZyH8QA?S1b^G&KY-oOO%U^wVm#dZj{>`&xuCoOV}$Fk{H=}4fc?L{ zF}Fa@*TC|42j{6c7X!Qfm%qJ%otH$G6Iy&G1|RClWU*F@U^F^q&ZU<}XH1_xhd;Ox ztLRLf!#OQ7%N8xiuHQtb&A4=O-Hhm^Q>V^um=m2-H+e<_i;w5u ztbE1*;pR*#+7?STV^PSdm#ZUj_Jp%*TI1R1f~IJ;tuuLJP2(afT7T8dx=W@{0a<>4 zW6~t|mo`RQ^79_K2(C)!|4>PhUn4O;Tk`Q+_WyL%@8gqx^1{*r`9%?bX+K3ypZvop X$NU(H_ai0#A7}BY#&49EA949#9ig*H literal 0 HcmV?d00001 -- 2.34.1