--- ../test//deadlock.cpp	2015-11-17 13:43:51.253746119 +0800
+++ ../test//2deadlock.cpp	2015-11-17 16:19:43.438026449 +0800
@@ -19,9 +19,9 @@
 		} 
 		i++;
 	}
-	pthread_mutex_lock(&lock2);
+	/* DFixer added:*/ /* DFixer multiple entries (clear)*/  if( ! preAcqTaken( & lock2 )) { pthread_mutex_lock( &lock2); }                           ;
 
-	pthread_mutex_unlock(&lock2);
+	/* DFixer added:*/ /* DFixer: loop */ if ( !preAcqTaken( & lock2) ) { pthread_mutex_unlock ( & lock2); }/* DFixer added:*/ /* DFixer multiple entries (clear) */  clearPreAcq( & lock2);                              ;
 }
 
 void f3() {
@@ -40,10 +40,10 @@
 
 void* f1 ( void* arg ) {
 
-	pthread_mutex_lock(&lock1);
+	/* DFixer added:*/ /* DFixer preAcquisitoin */ preAcq_pthread_mutex_lock(& lock1, & lock2); /* DFixer multiple entries (set) */ setPreAcqTaken ( & lock2 );                          ;
 
-	pthread_mutex_lock(&lock3); 
-	pthread_cond_wait(&cond, &lock3); //pthread_cond_wait(&cond, &lock1); 
+	/* DFixer added:*/ /* DFixer: handle other lock acquisitions */ setHWCondOn( &lock1, &lock2); pthread_mutex_unlock( &lock2); preAcq_pthread_mutex_lock( &lock3, &lock2); setHWCondOff( &lock1, &lock2);                          ; 
+	/* DFixer added:*/ /* DFixer: handle wait(k) */ setHWCondOn( &lock1, &lock2); pthread_mutex_unlock(&lock2); pthread_cond_wait(&cond, &lock3); pthread_mutex_unlock( &lock3); preAcq_pthread_mutex_lock( &lock3, &lock2); setHWCondOff( &lock1, &lock2);                                ; //pthread_cond_wait(&cond, &lock1); 
 	pthread_mutex_unlock(&lock3);
 	
 	printf("Test thread 1\n");
@@ -55,17 +55,17 @@
 	
 	if((int)(&lock2) % 3 == 1) 
 	{ printf("test\n");
-		f3();
+		f3();/* DFixer appended:*/ /* DFixer: loop */ if ( preAcqTaken( & lock2) ) { pthread_mutex_unlock ( & lock2 ); /* DFixer multiple entries (clear again) */  clearPreAcq( & lock2); } 
 	}
 
 _exit_:
-	pthread_mutex_unlock(&lock1);
+	/* DFixer added:*/ /* DFixer multiple exits */ if( ! preAcqTaken( & lock2 )) {pthread_mutex_unlock ( & lock2 ); /* DFixer multiple entries (clear again) */  clearPreAcq( & lock2); } pthread_mutex_unlock(&lock1);
 	
 	return NULL;
 }
 void* f2 ( void* arg ) {
 
-	pthread_mutex_lock(&lock2);
+	/* DFixer added:*/ /* DFixer: handle other lock acquisitions (the second thread) */  while(pthread_mutex_trylock(&lock2)){ if( getHWCond( &lock2, &lock1)) pthread_mutex_unlock(&lock2); else break; }                           ;
 
 	printf("Test thread 2\n");
 
