text: #include "header.h"
  #include <chrono>
  #include <thread>
  
  #define MAX_DELAY 1000000
  #define MIN_DELAY 10
  
  std::atomic<bool> state(false);
  
  void lock() {
  	int delay = MIN_DELAY;
  	while(true){
  		while (state) { //std::memory_order_relaxed
  			;
  		}
  		if (!state.exchange(true,std::memory_order_acquire)){
  			return;
  		} else {
  			auto time_to_sleep = std::chrono::microseconds( delay );
  			if (delay < MAX_DELAY) {
  				delay = delay << 1;
  			}
  			std::this_thread::sleep_for(time_to_sleep);
  		}
  	}
  }
  
  void unlock() {
  	state.exchange(false,std::memory_order_release);
  }
  
  void func(Operation * process_operation){
  	for(int i=0; i<L; i++){
  		lock();
  			//computation
  			process_operation->process();
  		unlock();
  	}
  }
  
  int main(int argc, char * argv[]){
  
  	if(argc < 3) {
  		printf("please use: %s <num_threads> <computation_intensity ( 1 for low | 2 for high | 3 for mixed)>\n", argv[0]);
  		return 1;
  	}
  	int num_threads = atoi(argv[1]);
  	omp_set_num_threads(num_threads);
  
  	int mode = atoi(argv[2]);
  	Operation * process_operation;
  	if (mode == 1){
  		process_operation = new Operation(1);
  	} else if (mode == 2){
  		process_operation = new Operation(2);
  	} else if (mode == 3){
  		process_operation = new Operation(3);
  		set_mixed_computation_key();
  	} else {
  		printf("Unidentified computation intensity!\n");
  		printf("please use: %s <num_threads> <computation_intensity ( 1 for low | 2 for high | 3 for mixed)>\n", argv[0]);
  		return 1;
  	}
  
  	counter = 0;
  
  	double start = time_stamp();
  
  	#pragma omp parallel
  	{
  		func(process_operation);
  	}
  
  	double end = time_stamp();
  
  	printf("Execution time Backoff Exponential: %f\n", end-start);
      printf("Actual Count: %d | Expected Count: %d\n",
                                          counter, (int)L*num_threads);
  
      printf("----------------------------------------------------- \n");
  
  	return 0;
  }