int main(int argc, char* argv[]) {
	VirtualCPU cpu0;
	initCPU(&cpu0);

  	//initialise the program
	Settings* set = setup(argc,argv);
	header(set->htmloutput);
	list_Job* list=FileToJobList(set->jobinput); // list would be sorted on arrival time
	list_Job_sort(list, compare_Job_Arrival);

	setSchedulingMode(&cpu0,set->mode);
	setRoundRobinCPUQuanta(&cpu0,set->rr_quanta);
	setMemoryManagement(&cpu0,set->mem_management);

	int clock=cpu0.current_clock;
	int totalclocks=0;
	int startclocks=clock;

	list_iterator_Job* it = malloc(sizeof(*it));
	list_Job_iterator_init(it, list);

	Job* current = list_Job_examine(it);
	while(current!=NULL){
		while(current!=NULL && clock==current->arrival_time){
			if(current->arrival_time < clock){
				//Error when process is behind the clock
				fprintf(stderr,"Process to be scheduled in the past- ERROR\n");
				exit(EXIT_FAILURE);
			}


			if(totalclocks==0)
				startclocks=clock;
			totalclocks+=current->length_time;

			debug_print("%s: %d @ %d \n",current->jobname,current->arrival_time,clock);
			addJobToCPU(&cpu0,current);		
			current= list_Job_next(it);
		}
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
		
	}
	free(list);
	while(isCPUIdle(&cpu0)==false){
		debug_print("Incrementing clock %d\n",clock);
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
	}
	debug_print_string("Complete!\n");

	list_JobScheduleResult* results = getResults(&cpu0);
	printResultsCompressed(results);

	footer(set->htmloutput);

	return 0;
}
Beispiel #2
0
// This is invoked in response to a timer interrupt.
// It does 2 things: 1) debounce switches, and 2) advances the time.
void timer_interrupt_handler() {
	uint32_t seconds = 0;
	uint32_t minutes = 0;
	uint32_t hours = 0;

	if (++counter == ONE_SECOND && !in_auto_increment_mode()){
		// clear the counter, it's been a second
		counter = 0;

		// increment the clock
		incrementClock();
	} else if (++refresh_counter == FAST_COUNT_MAX) {
		// clear the counter, it's time to refresh
		refresh_counter = 0;

		// grab the clock values so we can print them out
		getClock(&seconds, &minutes, &hours);

		// make sure to backspace so clock changes in place
		xil_printf("\b\b\b\b\b\b\b\b%02d:%02d:%02d", hours, minutes, seconds);
	}

	// let the bouncer know an interrupt occurred so it can debounce the button
	if (bouncing) tick_bouncer();

}
Beispiel #3
0
void TimingService::tick(){
	_absoluteClock++;
	if(_requests.getHead() == NULL)
		_relativeClock=0;
	else
		_relativeClock++;
	if (_absoluteClock % TICKS_PER_SECOND == 0){
		incrementClock();
	}
	checkPendingReq();
}