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 b4cb1a2..be5b47c 100755 Binary files a/Sim03/sim03 and b/Sim03/sim03 differ diff --git a/Sim03/simulator.c b/Sim03/simulator.c index df0ef2a..f3229e7 100644 --- a/Sim03/simulator.c +++ b/Sim03/simulator.c @@ -440,12 +440,23 @@ void memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offs break; case MEMORY_DEALLOCATE: + if (memDisplay) + { + // + printf("--------------------------------------------------\n"); + printf("After memory deallocate\n"); + printf("Deallocated memory chunk.\n"); + printf("--------------------------------------------------\n"); + } + break; + + case MEMORY_CLEAR: if (memDisplay) { // printf("--------------------------------------------------\n"); printf("After memory clear\n"); - printf("No memory configured"); + printf("No memory configured\n"); printf("--------------------------------------------------\n"); } break; @@ -590,8 +601,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr) // Operating System start timer goes here, log it. sprintf(simulatorOutput, "%f, OS: Simulator start\n", accessTimer(LAP_TIMER, timeStringy)); logOutput(configPtr, simulatorOutput, false); - - // int variable for process to run + // int variable for process to run int currentPid; // create the process list with createProcessList, store the pointed to address pcbList = createProcessList(); @@ -652,6 +662,8 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr) pcbPtr = pcbList->headPtr; } pthread_join(cpuThread, NULL); + // deallocate all the memory for each process. + memManager(pcbList, MEMORY_CLEAR, memoryOffset, memorySize, configPtr); sprintf(simulatorOutput, "%f, OS: System Stop\n", accessTimer(LAP_TIMER, timeStringy)); logOutput(configPtr, simulatorOutput, false); sprintf(simulatorOutput, "%f, OS: Simulation End\n", accessTimer(LAP_TIMER, timeStringy)); diff --git a/Sim03/simulator.h b/Sim03/simulator.h index f75f791..4ce4906 100644 --- a/Sim03/simulator.h +++ b/Sim03/simulator.h @@ -21,6 +21,7 @@ typedef enum{ MEMORY_INITIALIZE = 0, MEMORY_ACCESS, MEMORY_ALLOCATE, + MEMORY_CLEAR, MEMORY_DEALLOCATE } MEMORY_SIGNALS;