/** ISR for Timer 2 * @pre timer configured with initTimer * @pre global interrupts enabled with HAL_ENABLE_INTERRUPTS() */ void Timer2IntHandler(void) { // Clear the timer interrupt ROM_TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT); // Call the timerIsr function pointer timerIsr(); }
__interrupt void Timer_A0 (void) { timerIsr(); if (wakeupFlags & WAKEUP_AFTER_TIMER) { HAL_WAKEUP(); } }
void cpu() { genProcesses(); printf("\r\nBegin Simulation:\r\n\r\n"); int simCounter = 0; while (simCounter <= SIMULATION_END) { //check for timer interrupt, if so, call timerISR() if (timerCheck() == 1) { //printf("Timer interrupt: PID %d was running, ", PCBGetID(currProcess)); // if (PCBGetState(currProcess) != terminated) { genProcesses(); if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) { printf("Timer interrupt: PID %d was running, ", PCBGetID(currProcess)); } else { printf("Timer interrupt: no current process is running, "); } timerIsr(); } /****Checking for IO interrupts*****/ //check if there has been an IO interrupt, if so call appropriate ioISR if (checkIOInterrupt(device1) == 1) { if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) { printf("I/O 1 Completion interrupt: PID %d is running, ", PCBGetID(currProcess)); } else { printf("I/O 1 Completion interrupt: no current process is running, "); } //call the IO service routine IO_ISR(1); } if (checkIOInterrupt(device2) == 1) { if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) { printf("I/O 1 Completion interrupt: PID %d is running, ", PCBGetID(currProcess)); } else { printf("I/O 1 Completion interrupt: no current process is running."); } //call the IO service routine IO_ISR(2); } //check the current process's PC, if it is MAX_PC, set to 0 and increment TERM_COUNT if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/ && sysStackPC >= PCBGetMaxPC(currProcess)) { PCBSetTermCount(currProcess, PCBGetTermCount(currProcess) + 1); printf("\r\n"); //if TERM_COUNT = TERMINATE, then call terminateISR to put this process in the terminated list if (PCBGetTermCount(currProcess) == PCBGetTerminate(currProcess)) { terminateIsr(); continue; //currProcess has been terminated, we don't want to execute the rest of the loop, instead jump to next iteration } //PCBSetPC(currProcess, 0); sysStackPC = 0; } sysStackPC++; /***Checking traps*****/ if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/ && checkIORequest(1) != 0) { printf("I/O trap request: I/O device 1, "); IOTrapHandler(device1); } if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/ && checkIORequest(2) != 0) { printf("I/O trap request: I/O device 2, "); IOTrapHandler(device2); } //at end simCounter++; } }