Upload Sim02 files for Syncronization.
+- simulator.c/h
This commit is contained in:
parent
62418ec35a
commit
c828913809
2 changed files with 62 additions and 7 deletions
|
|
@ -6,14 +6,14 @@
|
||||||
/*
|
/*
|
||||||
Name: createProcessList
|
Name: createProcessList
|
||||||
Process: reads through the opcode struct to fill out the linked list of PCBs
|
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/Parameters: none
|
||||||
Function Output/Returned: head pointer to the PCBs
|
Function Output/Returned: head pointer to the PCBs
|
||||||
Device Input/Device: none
|
Device Input/Device: none
|
||||||
Device Output/Device: none
|
Device Output/Device: none
|
||||||
Dependencies: malloc, sizeof, ???
|
Dependencies: malloc, sizeof, ???
|
||||||
*/
|
*/
|
||||||
ProcessControlBlockLL *createProcessList(OpCodeType *metadataPtr)
|
ProcessControlBlockLL *createProcessList()
|
||||||
{
|
{
|
||||||
// allocate and create the ProcessControlBlockLL using malloc and size of
|
// allocate and create the ProcessControlBlockLL using malloc and size of
|
||||||
ProcessControlBlockLL *headBlock;
|
ProcessControlBlockLL *headBlock;
|
||||||
|
|
@ -68,6 +68,43 @@ ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr)
|
||||||
return NULL;
|
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
|
Name: runSim
|
||||||
Process: primary simulation driver
|
Process: primary simulation driver
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,15 @@ Dependencies: ???
|
||||||
// Sim02 only requires FCFS working atm.
|
// Sim02 only requires FCFS working atm.
|
||||||
|
|
||||||
// need a function called createProcessList
|
// 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 ...
|
// and ...
|
||||||
|
|
||||||
|
// reads through the opcode struct to fill out the linked list of PCBs
|
||||||
|
|
||||||
// need a function called destroyProcessList
|
// need a function called destroyProcessList
|
||||||
// deallocated the ll of PCBs recursively, frees the rest of the struct.
|
// deallocated the ll of PCBs recursively, frees the rest of the struct.
|
||||||
|
|
||||||
|
|
@ -90,15 +96,15 @@ Dependencies: ???
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Name: createProcessList
|
Name: createProcessList
|
||||||
Process: reads through the opcode struct to fill out the linked list of PCBs
|
Process: initializes head pointer to the PCBs
|
||||||
Function Input/Parameters: metadata (OpCodeType *)
|
Function Input/Parameters: none
|
||||||
Function Output/Parameters: none
|
Function Output/Parameters: none
|
||||||
Function Output/Returned: head pointer to the PCBs
|
Function Output/Returned: head pointer to the PCBs
|
||||||
Device Input/Device: none
|
Device Input/Device: none
|
||||||
Device Output/Device: none
|
Device Output/Device: none
|
||||||
Dependencies: malloc, sizeof, ???
|
Dependencies: malloc, sizeof, ???
|
||||||
*/
|
*/
|
||||||
ProcessControlBlockLL *createProcessList(OpCodeType *metadataPtr);
|
ProcessControlBlockLL *createProcessList();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Name: destroyProcessList
|
Name: destroyProcessList
|
||||||
|
|
@ -124,6 +130,18 @@ Dependencies: free, destroyProcessListHelper(recursively), ???
|
||||||
*/
|
*/
|
||||||
ProcessControlBlock *destroyProcessListHelper(ProcessControlBlock *nodePtr);
|
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
|
Name: runSim
|
||||||
Process: primary simulation driver
|
Process: primary simulation driver
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue