int main(int argc, char *argv[]) { unsigned long long now; unsigned long long latency; FunctionalUnitManager fum("fu.txt"); fum.dumpFunctionalUnits(); // let's turn off the adder now = 100; #define ISSUE(mask, time) { fum.processAtIssue(mask, time); cout<<"ISSUE @ "<<time<<" Total Power: "<<fum.getTotalPower(time)<<endl; fum.dumpStats(time);} #define COMMIT(mask, time) { fum.processAtCommit(mask, time); cout<<"COMMIT @ "<<time<<" Total Power: "<<fum.getTotalPower(time)<<endl; fum.dumpStats(time);} ISSUE(OFF, 100); ISSUE(ADD, 110); COMMIT(OFF, 130); ISSUE(ADD , 200); return 0; }
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'); }
extern obj_t core_eval_cont(volatile obj_t cont, volatile obj_t values, obj_t handler) { eval_dyn_env = MAKE_RECORD(dyn_env, EMPTY_LIST, handler); if (sigsetjmp(eval_sigrestart, 1)) { /* On Linux, siglongjmp is 30X slower than longjmp. */ /* push exception... */ } else { switch (setjmp(eval_restart)) { case LT_THROWN: { cv_t ret = push_exception(cont, values); cont = ret.cv_cont; values = ret.cv_values; } break; case LT_HEAP_FULL: cont_root = cont; values_root = values; collect_garbage(); cont = cont_root; values = values_root; cont_root = make_uninitialized(); values_root = make_uninitialized(); break; case LT_NO_EXCEPTION: register_lowex_handler(handle_lowex); break; default: assert(false); } } while (!is_null(cont)) { cv_t ret = cont_proc(cont)(cont, values); cont = ret.cv_cont; values = ret.cv_values; COMMIT(); #if DEBUG_EVAL int n = 0; obj_t p; for (p = cont; !is_null(p); p = cont_cont(p)) n++; EVAL_LOG("values=%O cont depth=%d", values, n); #endif } deregister_lowex_handler(handle_lowex); eval_dyn_env = make_uninitialized(); EVAL_LOG("END values=%O", values); assert(is_null(CDR(values))); return CAR(values); }
void Clock::Commit () { unsigned short tocommit; //m_count += m_cycles; // this loop is here because a timer can trigger a dma which will take a // long time, during this time the lcd must draw and the timers continue while (m_cycles >= m_first) { m_count += m_cycles; tocommit = m_cycles; m_cycles = 0; m_lcd -= tocommit; while (m_lcd <= 0) LCD.TimeEvent(); m_sound -= tocommit; while (m_sound <= 0) { SOUND.TimeEvent(); // XXX freq m_sound += SOUND_PERIOD; } #define COMMIT(dev, obj) \ if (m_##dev != INT_MAX) \ { \ m_##dev -= tocommit; \ while (m_##dev <= 0) \ obj.TimeEvent(); \ } COMMIT(timer[0], TIMER0) COMMIT(timer[1], TIMER1) COMMIT(timer[2], TIMER2) COMMIT(timer[3], TIMER3) //COMMIT(battery, MEM) #undef COMMIT SetFirst(); } }
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); }