diff --git a/Sim02/simulator.c b/Sim02/simulator.c index 036d5cc..bc83a71 100644 --- a/Sim02/simulator.c +++ b/Sim02/simulator.c @@ -6,14 +6,14 @@ /* Name: createProcessList Process: reads through the opcode struct to fill out the linked list of PCBs -Function Input/Parameters: metadata (OpCodeType *) +Function Input/Parameters: none Function Output/Parameters: none Function Output/Returned: head pointer to the PCBs Device Input/Device: none Device Output/Device: none Dependencies: malloc, sizeof, ??? */ -ProcessControlBlockLL *createProcessList(OpCodeType *metadataPtr) +ProcessControlBlockLL *createProcessList() { // allocate and create the ProcessControlBlockLL using malloc and size of ProcessControlBlockLL *headBlock; @@ -68,6 +68,43 @@ ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr) return NULL; } +/* +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 Output/Parameters: none +Function Output/Returned: pointer to filled PCB (ProcessControlBlock *) +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +ProcessControlBlock *fillProcessList(OpCodeType *metadataPtr) +{ + // initialize function/variables + // need a working pointer for the metadata + // need a pointer to save the location of first metadata opcode + // need a variable to count how many IO cycles are in the process + // need a variable to count how many CPU cycles are in the process + // need a variable to calculate the time left in ms for a process + // temp variables? + // loop through the process list, until you hit a sys end. + // if app start, + // set the unique ID + // set the process state to PROCESS_STATE_NEW + // set the nextOpCode as a pointer to the first place metadataPtr started + // loop while no longer have io or cpu instructions? + // count number of io cycles + // count number of cpu cycles + // set the ioCycles from variable + // set the cpuCycles from variable + // set totalCycles from adding both IO/CPU + // set the time left from (ioCycles * ioCycleRate) + (cpuCycles * procCyclesRate) + // this gets the number of ms in the process. + // return null (temp) + return (ProcessControlBlock *)NULL; +} + /* Name: runSim Process: primary simulation driver diff --git a/Sim02/simulator.h b/Sim02/simulator.h index 9a9a0a4..ffafb2a 100644 --- a/Sim02/simulator.h +++ b/Sim02/simulator.h @@ -78,9 +78,15 @@ Dependencies: ??? // Sim02 only requires FCFS working atm. // need a function called createProcessList -// this makes a linked list of PCBs, loads the first instruction after app start +// this initializes the process control block ll. + +// need a function called fillProcessList +// this fills the linked list of PCBs, +// loads the first instruction after app start // and ... +// reads through the opcode struct to fill out the linked list of PCBs + // need a function called destroyProcessList // deallocated the ll of PCBs recursively, frees the rest of the struct. @@ -90,15 +96,15 @@ Dependencies: ??? /* Name: createProcessList -Process: reads through the opcode struct to fill out the linked list of PCBs -Function Input/Parameters: metadata (OpCodeType *) +Process: initializes head pointer to the PCBs +Function Input/Parameters: none Function Output/Parameters: none Function Output/Returned: head pointer to the PCBs Device Input/Device: none Device Output/Device: none Dependencies: malloc, sizeof, ??? */ -ProcessControlBlockLL *createProcessList(OpCodeType *metadataPtr); +ProcessControlBlockLL *createProcessList(); /* Name: destroyProcessList @@ -124,11 +130,23 @@ Dependencies: free, destroyProcessListHelper(recursively), ??? */ ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr); +/* +Name: fillProcessList +Process: iterates through the metadata LL, fills out each process as needed. +Function Input/Parameters: metadata (OpCodeType *) +Function Output/Parameters: none +Function Output/Returned: none +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +ProcessControlBlock *fillProcessList(OpCodeType *metadataPtr); + /* Name: runSim Process: primary simulation driver Function Input/Parameters: configuration data (ConfigDataType *), - metadata (OpCodeType *) + metadata (OpCodeType *) Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none