#ifndef SIMULATORX #define SIMULATORX #include "StandardConstants.h" #include "configops.h" #include "metadataops.h" #include "simtimer.h" #include // data structures typedef enum{ PROCESS_STATE_NEW = 0, PROCESS_STATE_READY, PROCESS_STATE_RUNNING, PROCESS_STATE_BLOCKED, PROCESS_STATE_TERMINATED } PROCESS_STATES; typedef enum{ MEMORY_INITIALIZE = 0, MEMORY_ACCESS, MEMORY_ALLOCATE, MEMORY_CLEAR, MEMORY_DEALLOCATE } MEMORY_SIGNALS; typedef struct ProcessControlBlockStruct { int uniquePid; PROCESS_STATES process_state; // need a process start ptr for where the process starts. // this will be a mini loop within the master loop that goes until it // hits the app end command. // it may hold the next opcode, since you don't need to traverse backward OpCodeType *nextOpCode; // have an IO cycle count here int ioCycles; // have a CPU cycle count here int cpuCycles; // maybe have a total cycle count here int totalCycles; // time left could be calculated from these. // potentially could change the cycles or have a 'left' variable to // see how many are left. // also need a time left state here? double timeLeft; // allocated memory array (stores the offsets) int *allocatedMemOffsets; // allocated memory array sizes (stores the sizes for each offset) int *allocatedMemSizes; // size of memory array int memArraySize; // connect to the next process control block here struct ProcessControlBlockStruct *nextPtr; } ProcessControlBlock; typedef struct ProcessControlBlockLLStruct { // holds the head ptr for PCBs ProcessControlBlock *headPtr; } ProcessControlBlockLL; /* Name: ??? Process: ??? Function Input/Parameters: ??? Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: ??? */ /* Name: ??? Process: ??? Function Input/Parameters: ??? Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: ??? */ /* Name: addProcess Process: allocates the memory for the pcb, grabs the data from the created PCB, dumps the data so that the node can be linked correctly. Function Input/Parameters: source PCB (ProcessControlBlock) Function Output/Parameters: none Function Output/Returned: filled PCB (ProcessControlBlock *) Device Input/Device: none Device Output/Device: none Dependencies: malloc, sizeof, ??? */ ProcessControlBlock *addProcess(const ProcessControlBlock source); /* Name: createProcessList 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(); /* Name: destroyProcessList Process: deallocates memory used for the linked list struct Function Input/Parameters: head pointer to linked list (ProcessControlBlockLL *) Function Output/Parameters: none Function Output/Returned: NULL Device Input/Device: none Device Output/Device: none Dependencies: free, destroyProcessListHelper, ??? */ ProcessControlBlockLL *destroyProcessList(ProcessControlBlockLL *linkedListPtr); /* Name: destroyProcessListHelper Process: recursively clears the PCB linked list struct, freeing the struct Function Input/Parameters: head pointer to linked list (ProcessControlBlockLL *) Function Output/Parameters: none Function Output/Returned: NULL Device Input/Device: none Device Output/Device: none 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 *), headPointer (ProcessControlBlockLL *) Function Output/Parameters: none Function Output/Returned: pointer to filled PCB (ProcessControlBlockLL *) Device Input/Device: none Device Output/Device: none Dependencies: ??? */ ProcessControlBlockLL *fillProcessList(ConfigDataType *configPtr, OpCodeType *metadataPtr, ProcessControlBlockLL *headPointer); /* Name: findMin Process: compares two values, returns the smaller of the two. Function Input/Parameters: two integer values (int) Function Output/Parameters: none Function Output/Returned: minimum of the two input integer values (int) Device Input/Device: none Device Output/Device: none Dependencies: none */ int findMin(int one, int another); /* Name: logOutput Process: Takes in a string, and then outputs it to monitor AND/OR file Function Input/Parameters: string (char *), file pointer (FILE *), configuration data (ConfigDataType *), end of simulator (bool) Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: sprintf, ??? */ void logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd); /* Name: runCPU Process: runs the CPU operations for however long it takes Function Input/Parameters: ??? Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: ??? */ void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId); /* Name: runIO Process: runs the IO operations for however long it takes Function Input/Parameters: ??? Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: ??? */ void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId); /* Name: runSim Process: primary simulation driver Function Input/Parameters: configuration data (ConfigDataType *), metadata (OpCodeType *) Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none 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); /* Name: simThread Process: wrapper functions for threading in the simulator Function Input/Parameters: milliseconds (int) Function Output/Parameters: none Function Output/Returned: none Device Input/Device: none Device Output/Device: none Dependencies: ??? */ // void *simThread(int milSec); #endif // SIMULATORX