diff --git a/Sim03/logfile_1.lgf b/Sim03/logfile_1.lgf index 0a374fe..52b0e91 100644 --- a/Sim03/logfile_1.lgf +++ b/Sim03/logfile_1.lgf @@ -1,4 +1,4 @@ -0.000001, OS: Simulator start +0.000000, OS: Simulator start READY state from NEW state ate diff --git a/Sim03/sim03 b/Sim03/sim03 index 6b254d6..fa0a6df 100755 Binary files a/Sim03/sim03 and b/Sim03/sim03 differ diff --git a/Sim03/simulator.c b/Sim03/simulator.c index f5acfb5..e878dff 100644 --- a/Sim03/simulator.c +++ b/Sim03/simulator.c @@ -1,5 +1,20 @@ #include "simulator.h" +/* +Name: accessMemory +Process: checks offset from the PCB +Function Input/Parameters: source PCB (ProcessControlBlock *), offset (int), size (int) +Function Output/Parameters: none +Function Output/Returned: none? +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +void accessMemory(ProcessControlBlock *singlePCB, int offset, int size) +{ + // no return, void (temp) +} + /* Name: addProcess Process: allocates the memory for the pcb, grabs the data from the created PCB, @@ -31,6 +46,21 @@ ProcessControlBlock *addProcess(const ProcessControlBlock source) return workingNode; } +/* +Name: allocMemory +Process: 'allocates' memory within the PCB, stores offset and size within it's PCB +Function Input/Parameters: source PCB (ProcessControlBlock *), offset (int), size (int) +Function Output/Parameters: none +Function Output/Returned: none? +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +void allocMemory(ProcessControlBlock *singlePCB, int offset, int size) +{ + // no return, void (temp) +} + /* Name: createProcessList Process: reads through the opcode struct to fill out the linked list of PCBs @@ -52,6 +82,21 @@ ProcessControlBlockLL *createProcessList() return headBlock; } +/* +Name: deallocMemory +Process: 'deallocates' memory within the PCB, removes offset and size within it's PCB +Function Input/Parameters: source PCB (ProcessControlBlock *), offset (int), size (int) +Function Output/Parameters: none +Function Output/Returned: none? +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +void deallocMemory(ProcessControlBlock *singlePCB, int offset, int size) +{ + // no return, void (temp) +} + /* Name: destroyProcessList Process: deallocates memory used for the linked list struct @@ -304,6 +349,46 @@ void logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd) } } +/* +Name: memManager +Process: checks to make sure an allocate will be successful, + makes sure that an access will not segfault (or return segfault if it does), + and initializes memory and deallocates memory +Function Input/Parameters: PCBList (ProcessControlBlockLL *), memory code (MEMORY_SIGNALS), + offset (int), size (int), configuration data (ConfigDataType *) +Function Output/Parameters: none +Function Output/Returned: none? +Device Input/Device: none +Device Output/Device: none +Dependencies: ??? +*/ +void memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr) +{ + // switch case for each memory code + switch (memCode) + { + case MEMORY_INITIALIZE: + /* code */ + break; + + case MEMORY_ALLOCATE: + /* code */ + break; + + case MEMORY_ACCESS: + /* code */ + break; + + case MEMORY_DEALLOCATE: + /* code */ + break; + + default: + break; + } + // no return, void (temp) +} + /* Name: runCPU Process: runs the CPU operations for however long it takes diff --git a/Sim03/simulator.h b/Sim03/simulator.h index 4ccba46..30541cb 100644 --- a/Sim03/simulator.h +++ b/Sim03/simulator.h @@ -17,6 +17,13 @@ typedef enum{ PROCESS_STATE_TERMINATED } PROCESS_STATES; +typedef enum{ + MEMORY_INITIALIZE = 0, + MEMORY_ACCESS, + MEMORY_ALLOCATE, + MEMORY_DEALLOCATE + } MEMORY_SIGNALS; + typedef struct ProcessControlBlockStruct { int uniquePid; @@ -37,6 +44,10 @@ typedef struct ProcessControlBlockStruct // 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; // connect to the next process control block here struct ProcessControlBlockStruct *nextPtr; } ProcessControlBlock;