*** empty log message ***
authornavid <navid>
Tue, 10 Feb 2009 17:50:20 +0000 (17:50 +0000)
committernavid <navid>
Tue, 10 Feb 2009 17:50:20 +0000 (17:50 +0000)
Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/thread1.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java
Robust/Transactions/dstm2/src/dstm2/SpecialLock.java
Robust/Transactions/dstm2/src/dstm2/SpecialTransactionalFile.java
Robust/Transactions/dstm2/src/dstm2/Thread.java
Robust/Transactions/dstm2/src/dstm2/Transaction.java
Robust/Transactions/dstm2/src/dstm2/manager/BackoffManager.java
Robust/Transactions/dstm2/src/dstm2/manager/SpecialManager.java

index 4a31551d7c6fdde274a628cb9f68d65ac4dbfb70..5d557d6dbd814302be5489c57783302a687f07d7 100644 (file)
@@ -196,6 +196,7 @@ public class benchmark {
                 m.put(String.valueOf((char) (index + i)) + "random", new RandomAccessFile("/home/navid/" + String.valueOf((char) (index + i)) + ".text", "rw"));
                 m.put(String.valueOf((char) (index + i)), new TransactionalFile("/home/navid/" + String.valueOf((char) (index + i)) + ".text", "rw"));
                 m.put(String.valueOf((char) (index + i)), new TransactionalFile("/scratch/TransactionalIO/PureIOBenchmarkFiles/" + String.valueOf((char) (index + i)) + ".text", "rw"));
+                
                 count++;
             }   
             m.put("counterdstm2output", new RandomAccessFile("/scratch/TransactionalIO/WordCunterBenchmarkFiles/counter_benchmark_output.text", "rw"));
index e2174af3fcd9b4f9117a471468b1608ac7e0c99b..079dd1220fff9e600e94f05456cb742bbde1c6a4 100644 (file)
@@ -55,8 +55,8 @@ public class thread1 implements TransactionalProgram{
    
     public void execute() {
         try {
-            //TransactionalFile f1 = (TransactionalFile)benchmark.TransactionalFiles.get("0");
-            TransactionalFile f1;
+            TransactionalFile f1 = (TransactionalFile)benchmark.TransactionalFiles.get("0");
+            //TransactionalFile f1;
             if (tf != null) {
                 f1 = tf;
             } else {
index e804d736288d587a319aec935b035511b59080e9..26182aea3844a4486277d62dc805487c58569280 100644 (file)
@@ -205,7 +205,7 @@ public class ExtendedTransaction implements TransactionStatu {
         //while (iter.hasNext()/* && (this.getStatus() == Status.ACTIVE)*/) {
           //  INode key = (INode) iter.next();
             //Vector vec = (Vector) AccessedFiles.get(key);
-            INode key = entry.getKey();
+            //INode key = entry.getKey();
             Vector vec = entry.getValue();
             Collections.sort(vec);
             for (int i = 0; i < vec.size(); i++) {
index db872b19866eb94cc422d5531d4e07109bb922b9..dd1338b626f7c07c4ad587041b93997a8f064def 100644 (file)
@@ -7,27 +7,45 @@ package dstm2;
 
 
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  *
  * @author navid
  */
-public class SpecialLock extends ReentrantLock{
+public class SpecialLock{
     private static SpecialLock instance = null;
     private Transaction ownerTransaction = null;
+    private boolean locked = false;
 
     private SpecialLock() {
     }
     
     
     public synchronized void lock(Transaction tr){
-        super.lock();
-        setOwnerTransaction(tr);
+        try {
+            //System.out.println("trying to lock " + Thread.currentThread());
+            //super.lock();
+            while (locked)
+                wait();
+            locked = true;
+            setOwnerTransaction(tr);
+            Thread.getTransaction().setIOTransaction(true);
+           // System.out.println(Thread.currentThread() + " locked the lock");
+        } catch (InterruptedException ex) {
+            Logger.getLogger(SpecialLock.class.getName()).log(Level.SEVERE, null, ex);
+        }
     }
     
     public synchronized void unlock(Transaction tr){
-        super.unlock();
+     //   System.out.println(Thread.currentThread() + " unlocking the lock");
+        //super.unlock();
+        locked = false;
         setOwnerTransaction(null);
+        Thread.getTransaction().setIOTransaction(false);
+        notifyAll();
+       // System.out.println(Thread.currentThread() + " unlocked the lock");
     }
     
     public synchronized void setOwnerTransaction(Transaction tr){
@@ -38,13 +56,16 @@ public class SpecialLock extends ReentrantLock{
         return ownerTransaction;
     }
     
-    public synchronized static SpecialLock getSpecialLock(){
+    public synchronized  static SpecialLock getSpecialLock(){
         if (instance == null){ 
+           // System.out.println(Thread.currentThread() + " lock");
             instance = new SpecialLock();
             return instance;
         }
-        else
+        else{
+           // System.out.println(Thread.currentThread() + " lock-ret");
             return instance;    
+        }
         
     }
 
index 2a3e44bc42cd6d6e2387d774d79ab86c5141728d..bb9b23d17ab15bdc9417f34426d8184b5a7550c3 100644 (file)
@@ -2,10 +2,9 @@
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
-
 package dstm2;
 
-import TransactionalIO.core.Wrapper;
+
 import TransactionalIO.exceptions.AbortedException;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -16,10 +15,10 @@ import java.io.RandomAccessFile;
  *
  * @author navid
  */
-public class SpecialTransactionalFile{
-    
-    RandomAccessFile raFile;
-    
+public class SpecialTransactionalFile {
+
+    public RandomAccessFile raFile;
+
     public SpecialTransactionalFile(File arg0, String arg1) throws FileNotFoundException {
         raFile = new RandomAccessFile(arg0, arg1);
     }
@@ -28,199 +27,180 @@ public class SpecialTransactionalFile{
         raFile = new RandomAccessFile(arg0, arg1);
     }
 
-    
-    private void checkConsisteny(){
-      //    System.out.println(Thread.currentThread());
+    private void checkConsisteny() {
+        
         Transaction me = Thread.getTransaction();
+        if (me ==  null)
+            return;
+        
         if (!me.isActive()) {
-                SpecialLock.getSpecialLock().unlock(me);
-                throw new AbortedException();
+
+            throw new AbortedException();
         }
-        if (me != SpecialLock.getSpecialLock().getOwnerTransaction()){
-          //  System.out.println("trying to lock " + Thread.currentThread());
+        
+        if (me != SpecialLock.getSpecialLock().getOwnerTransaction()) {
+        //if (!(me.isIOTransaction())){
             SpecialLock.getSpecialLock().lock(me);
-           // System.out.println("locked " + Thread.currentThread());
         }
-        
+
         if (!me.isActive()) {
-                SpecialLock.getSpecialLock().unlock(me);
-                throw new AbortedException();
+            throw new AbortedException();
         }
-        
+
     }
-    
-    
+
     public void close() throws IOException {
         checkConsisteny();
         raFile.close();
     }
 
-    
     public long getFilePointer() throws IOException {
         checkConsisteny();
         return raFile.getFilePointer();
     }
 
-    
     public long length() throws IOException {
         checkConsisteny();
         return raFile.length();
     }
 
-    
     public int read() throws IOException {
         checkConsisteny();
         return raFile.read();
     }
 
-    
     public int read(byte[] arg0, int arg1, int arg2) throws IOException {
         checkConsisteny();
         return raFile.read(arg0, arg1, arg2);
     }
 
-    
     public int read(byte[] arg0) throws IOException {
         checkConsisteny();
         return raFile.read(arg0);
     }
 
-    
     public void seek(long arg0) throws IOException {
         checkConsisteny();
         raFile.seek(arg0);
     }
 
-    
     public void setLength(long arg0) throws IOException {
         checkConsisteny();
         raFile.setLength(arg0);
     }
 
-    
     public int skipBytes(int arg0) throws IOException {
         checkConsisteny();
         return raFile.skipBytes(arg0);
     }
 
-    
     public void write(int arg0) throws IOException {
         checkConsisteny();
         raFile.write(arg0);
     }
 
-    
     public void write(byte[] arg0) throws IOException {
         checkConsisteny();
         raFile.write(arg0);
     }
 
-    
     public void write(byte[] arg0, int arg1, int arg2) throws IOException {
         checkConsisteny();
         raFile.write(arg0, arg1, arg2);
     }
-    
-    public final void writeInt(int integer) throws IOException{
+
+    public final void writeInt(int integer) throws IOException {
         checkConsisteny();
         raFile.writeInt(integer);
     }
-    
-    public final int readInt() throws IOException{
+
+    public final int readInt() throws IOException {
         checkConsisteny();
         return raFile.readInt();
     }
-    
-    public final void writeBoolean(boolean bool) throws IOException{
+
+    public final void writeBoolean(boolean bool) throws IOException {
         checkConsisteny();
         raFile.writeBoolean(bool);
     }
-    
-    public final boolean readBoolean() throws IOException{
+
+    public final boolean readBoolean() throws IOException {
         checkConsisteny();
         return raFile.readBoolean();
     }
-    
-    public final void writeUTF(String val) throws IOException{
+
+    public final void writeUTF(String val) throws IOException {
         checkConsisteny();
         raFile.writeUTF(val);
     }
-    
-    public final String readUTF() throws IOException{
+
+    public final String readUTF() throws IOException {
         checkConsisteny();
         return raFile.readUTF();
     }
-    
-    public final void writeShort(short val) throws IOException{
+
+    public final void writeShort(short val) throws IOException {
         checkConsisteny();
         raFile.writeShort(val);
     }
-    
-    public final short readShort() throws IOException{
+
+    public final short readShort() throws IOException {
         checkConsisteny();
         return raFile.readShort();
     }
-    
-      public final void writeByte(byte arg0) throws IOException{
+
+    public final void writeByte(byte arg0) throws IOException {
         checkConsisteny();
         raFile.writeByte(arg0);
     }
-    
-    public final byte readByte() throws IOException{
+
+    public final byte readByte() throws IOException {
         checkConsisteny();
         return raFile.readByte();
     }
-    
-    public final void writeChar(int val) throws IOException{
+
+    public final void writeChar(int val) throws IOException {
         checkConsisteny();
         raFile.writeChar(val);
     }
-    
-    public final char readChar() throws IOException{
+
+    public final char readChar() throws IOException {
         checkConsisteny();
         return raFile.readChar();
     }
-    
-    public final void writeBytes(String val) throws IOException{
+
+    public final void writeBytes(String val) throws IOException {
         checkConsisteny();
         raFile.writeBytes(val);
     }
-    
-      public final void writeLong(long val) throws IOException{
+
+    public final void writeLong(long val) throws IOException {
         checkConsisteny();
         raFile.writeLong(val);
     }
-    
-    public final long readLong() throws IOException{
+
+    public final long readLong() throws IOException {
         checkConsisteny();
         return raFile.readLong();
     }
-    
-      public final void writeDouble(double arg0) throws IOException{
+
+    public final void writeDouble(double arg0) throws IOException {
         checkConsisteny();
         raFile.writeDouble(arg0);
     }
-    
-    public final double readDouble() throws IOException{
+
+    public final double readDouble() throws IOException {
         checkConsisteny();
         return raFile.readDouble();
     }
-    
-    public final void writeFloat(float val) throws IOException{
+
+    public final void writeFloat(float val) throws IOException {
         checkConsisteny();
         raFile.writeFloat(val);
     }
-    
-    public final float readFloat() throws IOException{
+
+    public final float readFloat() throws IOException {
         checkConsisteny();
         return raFile.readFloat();
     }
-    
-  
-    
-    
-    
-
-   
-    
 }
index f7da48d3b608dcbccfa165b99ff424d1e21a3e63..63f2193544ea7eaac2513f5628e78e6c25229d86 100644 (file)
@@ -251,13 +251,16 @@ public class Thread extends java.lang.Thread{
     try {
       while (true) {
         threadState.beginTransaction();
+               
      //   System.out.println(Thread.currentThread() + " offically started the transaction");
        /////For Integrating with IO////////// 
         Wrapper.Initialize(Thread.getTransaction());
+        //System.out.println(Thread.currentThread() + " starting");
       //  System.out.println(Thread.currentThread() + " even more offically started the transaction");
        ////////////////////////////////////// 
         try {
           result = xaction.call();
+        //  System.out.println(Thread.currentThread() + " starting2");
       //     System.out.println(Thread.currentThread() + " aborted in committing");
       //  } catch (AbortedException d) {
           /*  synchronized(benchmark.lock){
@@ -281,13 +284,16 @@ public class Thread extends java.lang.Thread{
                 if (threadState.commitTransaction()) {
                     threadState.committedMemRefs += threadState.transaction.memRefs;
                     
+                    
+                    Wrapper.realseOffsets();
+                    
                     Wrapper.commitIO();
                     flag = true;
                }
         }
         catch(AbortedException ex){
             threadState.depth--;
-           // System.out.println(Thread.currentThread() + " aborted");
+            //System.out.println(Thread.currentThread() + " aborted");
            // Wrapper.getTransaction().unlockAllLocks();
         }
         catch (Exception e) {
@@ -298,14 +304,20 @@ public class Thread extends java.lang.Thread{
             
           //  System.out.println("here " + Thread.currentThread());
             Wrapper.getTransaction().unlockAllLocks();
+               
             if (Thread.getTransaction() == SpecialLock.getSpecialLock().getOwnerTransaction()){
-            //     System.out.println("herein " + Thread.currentThread());
+            //if (Thread.getTransaction().isIOTransaction()){
+               
+              //   System.out.println("herein " + Thread.currentThread());
                 SpecialLock.getSpecialLock().unlock(Thread.getTransaction());
+               
             //    System.out.println("here");
-                        
+          ///              
             }
-            if  (flag == true)
+            if  (flag == true){
+               // System.out.println(Thread.currentThread() + " committed");
                 break;
+            }
         }
       
         // transaction aborted
index 76205241ef03a449ef6d655a3fc396e5e3a9d1e8..31cc240324b03c87999599f0757ae87e5d220eec 100644 (file)
@@ -48,6 +48,9 @@ public class Transaction implements TransactionStatu{
   
   private TransactionStatu othersystem; 
   private boolean flag = true;
+  private boolean IOTransaction = false;
+
+   
   /**
    * Possible transaction status
    **/
@@ -288,4 +291,12 @@ public class Transaction implements TransactionStatu{
     public void abortThisSystem() {
         abort();
     }
+    
+     public boolean isIOTransaction() {
+        return IOTransaction;
+    }
+
+    public void setIOTransaction(boolean IOTransaction) {
+        this.IOTransaction = IOTransaction;
+    }
 }
index 30f175babd9db49a57f0c9be955e0364f88b39e0..afa372cfc11de8be1e6ca45503debfcf408008a0 100644 (file)
@@ -58,6 +58,7 @@ public class BackoffManager extends BaseManager {
     currentAttempt = 0;
   }
   public void resolveConflict(Transaction me, Transaction other) {
+     //
     if (currentAttempt <= MAX_RETRIES) {
       if (!other.isActive()) {
         return;
@@ -78,6 +79,7 @@ public class BackoffManager extends BaseManager {
     }
   }
   public void resolveConflict(Transaction me, Collection<Transaction> others) {
+     
     if (currentAttempt <= MAX_RETRIES) {
       int logBackoff = currentAttempt - 2 + MIN_LOG_BACKOFF;
       if (logBackoff > MAX_LOG_BACKOFF) {
index 6f50871a993fa2dd7f1dc3a7d468dcb5dae83701..21b711d99d353636b507404e9751f57ed87edff9 100644 (file)
@@ -2,33 +2,58 @@
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
-
 package dstm2.manager;
 
+import TransactionalIO.core.Wrapper;
 import dstm2.SpecialLock;
 import dstm2.Transaction;
+import java.util.Collection;
 
 /**
  *
  * @author navid
  */
-public class SpecialManager extends PriorityManager{
-    
+public class SpecialManager extends BackoffManager {
+
+    @Override
     public void resolveConflict(Transaction me, Transaction other) {
-        if (me == SpecialLock.getSpecialLock().getOwnerTransaction())
+  
+        if (me == SpecialLock.getSpecialLock().getOwnerTransaction()) {
             other.abort();
-        else if (other == SpecialLock.getSpecialLock().getOwnerTransaction())
+        } else if (other == SpecialLock.getSpecialLock().getOwnerTransaction()) {
             me.abort();
-
-        else 
+        } 
+        else {
             super.resolveConflict(me, other);
-      }
+       }
+    }
+
+    @Override
+    public void resolveConflict(Transaction me, Collection<Transaction> others) {
+
+        if (me == SpecialLock.getSpecialLock().getOwnerTransaction()) {
+            for (Transaction other : others) {
+                if (other.isActive() && other != me) {
+                    other.abort();
+                }
+            }
+            return;
+        }
+        else  for (Transaction other : others) {
+            if (other == SpecialLock.getSpecialLock().getOwnerTransaction()){
+                me.abort();
+                return;
+            }
+        }
+        
+        super.resolveConflict(me, others);
+    }
 
-      public long getPriority() {
+    public long getPriority() {
         throw new UnsupportedOperationException();
-      }
+    }
 
-      public void setPriority(long value) {
+    public void setPriority(long value) {
         throw new UnsupportedOperationException();
-      }
+    }
 }