// Shahir Ahmed and Boosung Kim #include "umps3/umps/aout.h" #include "umps3/umps/arch.h" #include "umps3/umps/bios_defs.h" #include "umps3/umps/cp0.h" #include "umps3/umps/regdef.h" #include "umps3/umps/libumps.h" #include "../h/syscall.h" #include "../h/scheduler.h" #include "../h/exception_handler.h" int processCount; // number of started but not terminated processes int softBlockCount; // number of soft blocked processes pcb_t* readyQueue; // tail pointer to the queue of ready pcbs pcb_t* currentProcess; // pointer to the current executing process state_t initialState; // initial process state int device_semaphores[49]; // 49 device semaphores static passupvector_t* myPassUpVector; // pointer to pass up vector extern void uTLB_RefillHandler(); extern void exceptionHandler(); extern void test(); int main() { /* Nucleus initialization for pass up vector */ myPassUpVector = (passupvector_t*) 0x0FFFF900; myPassUpVector->tlb_refill_handler = (memaddr) uTLB_RefillHandler; myPassUpVector->tlb_refill_stackPtr = (memaddr) 0x20001000; myPassUpVector->exception_handler = (memaddr) exceptionHandler; myPassUpVector->exception_stackPtr = (memaddr) 0x20001000; /* Initialize level two data structures */ initPcbs(); initASL(); /* Initialize all nucleus maintained variables */ processCount = 0; softBlockCount = 0; readyQueue = mkEmptyProcQ(); currentProcess = NULL; for (int i = 0; i < 49; i++) { device_semaphores[i] = 0; } LDIT(100000); // 100ms (changed to new value in phase 2 part 5) /* Instantiate a single process, place its pcb in the ready queue, and increment processCount */ pcb_t* p = allocPcb(); p->p_time = 0; p->p_semAdd = NULL; p->p_supportStruct = NULL; /* Initialize process state and stack pointer */ STST(&initialState); RAMTOP(initialState.reg_sp); insertProcQ(&readyQueue, p); processCount++; initialState.pc_epc = (memaddr) test; initialState.reg_t9 = (memaddr) test; // 0000 1 0000 0 000000 11111111 00 000100 initialState.status = 0x800ff04; p->p_s = initialState; Scheduler(); return 0; }