diff --git a/Sim02/sim02 b/Sim02/sim02 index 5403898..05bf686 100755 Binary files a/Sim02/sim02 and b/Sim02/sim02 differ diff --git a/Sim02/simulator.c b/Sim02/simulator.c index 2193094..57fb9d4 100644 --- a/Sim02/simulator.c +++ b/Sim02/simulator.c @@ -87,10 +87,10 @@ ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr) /* Name: fillProcessList Process: iterates through the metadata LL, fills out each process as needed. -(Linking is left to the calling function, returns a pointer to the filled struct) -Function Input/Parameters: metadata (OpCodeType *) +Function Input/Parameters: metadata (OpCodeType *), + headPointer (ProcessControlBlockLL *) Function Output/Parameters: none -Function Output/Returned: pointer to filled PCB (ProcessControlBlock *) +Function Output/Returned: pointer to filled PCB (ProcessControlBlockLL *) Device Input/Device: none Device Output/Device: none Dependencies: ??? @@ -224,8 +224,8 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr) // currentTime variable that stores the time. [now unsure if needed] // need a variable for headPointer to point ProcessControlBlockLL *pcbList; - // string variable for nextCode - char *nextCode; + // string variable for nextCode, temp unused + // char *nextCode; // create the process list with createProcessList, store the pointed to address pcbList = createProcessList(); // fill the process list given the metadata @@ -241,7 +241,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr) // set the master working pointer to the first metadata block wkgPtrMaster = metaDataMstrPtr; // function holds master loop, loops until sys end opcode found OR wkgPtrMaster nextNode != NULL - while( wkgPtrMaster->nextNode != NULL || (compareString(argument, "end") && compareString(command, "sys"))) + while(wkgPtrMaster->nextNode != NULL || (compareString(argument, "end") && compareString(command, "sys"))) { // will have a loop that goes from app start to app end for a PCB // (checks to see if the next instruction is NOT app end), using getNextProcess? @@ -263,10 +263,56 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr) // void function, no return. } - // getNextProcess/scheduler/dispatcher run here, loads/"runs" the process - // getNextOpCode, not needed for Sim02 apparently, keep in mind. - // checkForIO, I think this gets passed the current process and runs the IO ops - // checkForCPU, I think this gets passed the current process and runs the CPU ops - // checkForMemory, I think this gets passed the current process - // and runs mem ops (not needed for Sim02) - // cpuIdler (not needed for Sim02) \ No newline at end of file +/* +Name: scheduleProcess +Process: takes in the scheduling data, and then returns which process is to be ran +Function Input/Parameters: head pointer of PCB List (ProcessControlBlockLL *), + configuration data (ConfigDataType *) +Function Output/Parameters: none +Function Output/Returned: none +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr) +{ + int returnPid = -1; + // switch case for each scheduling algorithm + switch (configPtr->cpuSchedCode) + { + case CPU_SCHED_FCFS_N_CODE: + // First Come, First Served, Non-preemptive Scheduling + // only one implemented for now. returns first process without fail. + // need to find whichever process is first, AND the state is NEW. + // will set the state to READY, return the pid of the process which + // was set to ready. + // ignores any process which has a state of TERMINATED + break; + case CPU_SCHED_FCFS_P_CODE: + // TODO: First Come, First Served, Preemptive Scheduling + break; + case CPU_SCHED_RR_P_CODE: + // TODO: Round Robin Scheduling + break; + case CPU_SCHED_SJF_N_CODE: + // TODO: Shortest Job First Scheduling + break; + case CPU_SCHED_SRTF_P_CODE: + // TODO: Shortest Run-time First Scheduling + break; + } + // return returnPid + return returnPid; +} +/* +Current Note to programmer: do the scheduler, the runIO and runCPU functions, and then the FILE IO functions +this is all that is left so far, hopefully not too bad. +*/ + +// getNextProcess/scheduler/dispatcher run here, loads/"runs" the process +// getNextOpCode, not needed for Sim02 apparently, keep in mind. +// checkForIO, I think this gets passed the current process and runs the IO ops +// checkForCPU, I think this gets passed the current process and runs the CPU ops +// checkForMemory, I think this gets passed the current process +// and runs mem ops (not needed for Sim02) +// cpuIdler (not needed for Sim02) \ No newline at end of file diff --git a/Sim02/simulator.h b/Sim02/simulator.h index 4b3dd8e..e9d5d58 100644 --- a/Sim02/simulator.h +++ b/Sim02/simulator.h @@ -133,9 +133,10 @@ ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr); /* Name: fillProcessList Process: iterates through the metadata LL, fills out each process as needed. -Function Input/Parameters: metadata (OpCodeType *) +Function Input/Parameters: metadata (OpCodeType *), + headPointer (ProcessControlBlockLL *) Function Output/Parameters: none -Function Output/Returned: none +Function Output/Returned: pointer to filled PCB (ProcessControlBlockLL *) Device Input/Device: none Device Output/Device: none Dependencies: ??? @@ -155,4 +156,16 @@ Dependencies: ??? */ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr); +/* +Name: scheduleProcess +Process: takes in the scheduling data, and then returns which process is to be ran +Function Input/Parameters: head pointer of PCB List (ProcessControlBlockLL *) +Function Output/Parameters: none +Function Output/Returned: none +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr); + #endif // SIMULATORX \ No newline at end of file