int main() { int outcome_record_nonce_id=1001;// id to initialise the transaction ids, this will be incremented everytime a new action is created int caller_id,read_value,new_value,abort_id; char operation,data_id,iterator,commit_boolean; READ_CURRENT_VALUE(data_id); do { printf("\nENTER THE DATA_ID\n"); scanf(" %c",&data_id); printf("data id you entered is:%c\n",data_id); printf("\n a.READ_CURRENT_VALUE \n b.WRITE_NEW_VALUE\n c.NEW_ACTION \n d.COMMIT \n e.ABORT \n f.GET_OUTCOME_RECORDS\n"); printf("enter the transaction you want to perform from above options:\n"); scanf(" %c",&operation); switch(operation) { case 'a': printf("READING CURRENT VALUE:\n"); caller_id=NEW_ACTION(outcome_record_nonce_id); read_value=READ_CURRENT_VALUE(data_id); if(read_value==-1) printf("no value found"); else printf("READ_CURRENT_VALUE=%d",read_value); break; case 'b': printf("ENTER THE VALUE TO WRITE:"); scanf("%d",&new_value); printf("WRITING NEW VALUE"); caller_id=NEW_ACTION(outcome_record_nonce_id); printf("caller_id is %d",caller_id); WRITE_NEW_VALUE(data_id,new_value,caller_id); printf("DO YOU WANT TO COMMIT THIS VALUE:Y/N"); scanf(" %c",&commit_boolean); if(commit_boolean=='Y') COMMIT(caller_id); outcome_record_nonce_id++; break; case 'c': printf("Only READ_CURRENT_VALUE or WRITE_NEW_VALUE can create a NEW_ACTION, please exit and start again\n"); break; case 'd': printf("Only post using WRITE_NEW_VALUE method you will be asked to COMMIT or not,please exit and start again\n"); break; case 'e': printf("Enter the transaction id you want to ABORT"); scanf("%d",&abort_id); ABORT(abort_id); break; case 'f' : GET_OUTCOME_RECORD(); break; default : printf("INVALID OPTION, PLEASE INPUT CORRECT OPERATION ID:"); break; } printf("do you wish to continue Y/N, Enter Y or N:"); scanf(" %c",&iterator); }while(iterator=='Y'); }
void *process_1(storage *mod){ int *ret=NULL; printf("\n---------------------PROCESS 1 STARTED------------------"); if(mod->cell_data==NULL){ printf("\nRead Error"); } ret=WRITE_NEW_VALUE(mod); ret=COMMIT(mod); if(*ret==1){ printf("\nCommit Error"); } mod=READ_CURRENT_VALUE(mod); if(mod->cell_data==NULL){ printf("\nRead Error"); } printf("\n---------------------PROCESS 1 FINISHED------------------"); pthread_exit(NULL); }