Compare commits
2 commits
638e55e77f
...
cff600c0cd
| Author | SHA1 | Date | |
|---|---|---|---|
| cff600c0cd | |||
| 9ea562bbfe |
5 changed files with 214 additions and 202 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
Start Simulator Configuration File:
|
Start Simulator Configuration File:
|
||||||
Version/Phase : 1.05
|
Version/Phase : 1.05
|
||||||
File Path : metadata5.mdf
|
File Path : metadata5.mdf
|
||||||
CPU Scheduling Code : SJF-N
|
CPU Scheduling Code : FCFS-P
|
||||||
Quantum Time (cycles) : 3
|
Quantum Time (cycles) : 3
|
||||||
Memory Available (KB) : 11100
|
Memory Available (KB) : 11100
|
||||||
Memory Display (On/Off) : On
|
Memory Display (On/Off) : On
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
0.000000, OS: Simulator start
|
0.000001, OS: Simulator start
|
||||||
|
|
|
||||||
BIN
Sim04/sim04
BIN
Sim04/sim04
Binary file not shown.
|
|
@ -89,6 +89,8 @@ Dependencies: ???
|
||||||
*/
|
*/
|
||||||
bool allocMemory(ProcessControlBlock *singlePCB, int offset, int size, int arraySize)
|
bool allocMemory(ProcessControlBlock *singlePCB, int offset, int size, int arraySize)
|
||||||
{
|
{
|
||||||
|
// printf("Memory Offset: %d\n", offset);
|
||||||
|
// printf("Memory Size: %d\n", size);
|
||||||
int allocateIterator = 0;
|
int allocateIterator = 0;
|
||||||
// while until a '-1' is hit, then store the value.
|
// while until a '-1' is hit, then store the value.
|
||||||
while(singlePCB->allocatedMemSizes[allocateIterator] != -1 && allocateIterator < arraySize)
|
while(singlePCB->allocatedMemSizes[allocateIterator] != -1 && allocateIterator < arraySize)
|
||||||
|
|
@ -397,6 +399,13 @@ ProcessControlBlockLL *fillProcessList(ConfigDataType *configPtr, OpCodeType *me
|
||||||
inOutArg = wkgMetaPtr->inOutArg;
|
inOutArg = wkgMetaPtr->inOutArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (configPtr->cpuSchedCode == CPU_SCHED_RR_P_CODE)
|
||||||
|
{
|
||||||
|
// if in round robin preemptive scheduling, then make the linked list
|
||||||
|
// into a circularly linked list, with the head pointer pointed to the
|
||||||
|
// first node, and the last node linked to the first.
|
||||||
|
wkgPCBPtr->nextPtr = headPointer->headPtr;
|
||||||
|
}
|
||||||
// return headPointer
|
// return headPointer
|
||||||
return headPointer;
|
return headPointer;
|
||||||
}
|
}
|
||||||
|
|
@ -455,7 +464,6 @@ bool interruptManager(ConfigDataType *configPtr, ProcessControlBlock *singlePCB,
|
||||||
// /* code */
|
// /* code */
|
||||||
// break;
|
// break;
|
||||||
case CLEAR_INTERRUPT:
|
case CLEAR_INTERRUPT:
|
||||||
// COMMENT HERE
|
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -478,7 +486,7 @@ Dependencies: fprintf, ???
|
||||||
logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFileLL *logPtr)
|
logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFileLL *logPtr)
|
||||||
{
|
{
|
||||||
logFile toLog;
|
logFile toLog;
|
||||||
logFile *logStrPtr;
|
// logFile *logStrPtr;
|
||||||
logFile *wkgLogPtr;
|
logFile *wkgLogPtr;
|
||||||
logFile *prevWkgLogPtr;
|
logFile *prevWkgLogPtr;
|
||||||
wkgLogPtr = logPtr->headPtr;
|
wkgLogPtr = logPtr->headPtr;
|
||||||
|
|
@ -521,8 +529,8 @@ logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFil
|
||||||
}
|
}
|
||||||
if (wkgLogPtr == NULL)
|
if (wkgLogPtr == NULL)
|
||||||
{
|
{
|
||||||
logStrPtr = addLog(toLog);
|
// logStrPtr = addLog(toLog);
|
||||||
// prevWkgLogPtr->nextPtr = addLog(toLog);
|
// prevWkgLogPtr->nextPtr = addLog(toLog); // THIS SHOULD BE THE WORKING LINE, but it doesn't.
|
||||||
// prevWkgLogPtr = addLog(toLog);
|
// prevWkgLogPtr = addLog(toLog);
|
||||||
// prevWkgLogPtr->nextPtr = logStrPtr;
|
// prevWkgLogPtr->nextPtr = logStrPtr;
|
||||||
// prevWkgLogPtr->nextPtr = logStrPtr;
|
// prevWkgLogPtr->nextPtr = logStrPtr;
|
||||||
|
|
@ -552,190 +560,192 @@ Device Input/Device: none
|
||||||
Device Output/Device: none
|
Device Output/Device: none
|
||||||
Dependencies: ???
|
Dependencies: ???
|
||||||
*/
|
*/
|
||||||
bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
// bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
||||||
ProcessControlBlock *singlePCB)
|
// ProcessControlBlock *singlePCB)
|
||||||
{
|
|
||||||
bool memDisplay = configPtr->memDisplay;
|
|
||||||
ProcessControlBlock *wkgPtr;
|
|
||||||
int availableMem = configPtr->memAvailable;
|
|
||||||
int usedMem = 0;
|
|
||||||
int currentOffset = 0;
|
|
||||||
int currentSize = 0;
|
|
||||||
int memIterator;
|
|
||||||
int *memorySizeArray;
|
|
||||||
int totalArraySize = 0;
|
|
||||||
bool subFunctionSuccess = true;
|
|
||||||
wkgPtr = pcbList->headPtr;
|
|
||||||
|
|
||||||
// grab how much memory is being used total, then count how big the total memory array should be
|
|
||||||
while(wkgPtr != NULL)
|
|
||||||
{
|
|
||||||
// count up the total used memory within each process control block.
|
|
||||||
for(memIterator = 0; memIterator < wkgPtr->memArraySize; memIterator++)
|
|
||||||
{
|
|
||||||
if(wkgPtr->allocatedMemSizes[memIterator] != -1)
|
|
||||||
{
|
|
||||||
// grab how much memory is used by that process
|
|
||||||
usedMem = usedMem + wkgPtr->allocatedMemSizes[memIterator];
|
|
||||||
}
|
|
||||||
totalArraySize = totalArraySize + 1;
|
|
||||||
}
|
|
||||||
// move to the next pointer
|
|
||||||
wkgPtr = wkgPtr->nextPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset the working pointer
|
|
||||||
wkgPtr = pcbList->headPtr;
|
|
||||||
|
|
||||||
// declare the array for the memory
|
|
||||||
memorySizeArray = malloc(sizeof(int) * totalArraySize);
|
|
||||||
|
|
||||||
// grab the entire memory structure, so that the memory can be contiguous
|
|
||||||
while (wkgPtr != NULL)
|
|
||||||
{
|
|
||||||
// count up the total used memory within each process control block.
|
|
||||||
for (memIterator = 0; memIterator < totalArraySize; memIterator++)
|
|
||||||
{
|
|
||||||
// grab how much memory is used by that process
|
|
||||||
memorySizeArray[memIterator] = wkgPtr->allocatedMemSizes[memIterator];
|
|
||||||
}
|
|
||||||
// move to the next pointer
|
|
||||||
wkgPtr = wkgPtr->nextPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// grab the size of the
|
|
||||||
// while()
|
|
||||||
// {
|
// {
|
||||||
// //
|
// // printf("Memory Offset: %d\n", offset);
|
||||||
|
// // printf("Memory Size: %d\n", size);
|
||||||
|
// bool memDisplay = configPtr->memDisplay;
|
||||||
|
// ProcessControlBlock *wkgPtr;
|
||||||
|
// int availableMem = configPtr->memAvailable;
|
||||||
|
// int usedMem = 0;
|
||||||
|
// int currentOffset = 0;
|
||||||
|
// int currentSize = 0;
|
||||||
|
// int memIterator;
|
||||||
|
// int *memorySizeArray;
|
||||||
|
// int totalArraySize = 0;
|
||||||
|
// bool subFunctionSuccess = true;
|
||||||
|
// wkgPtr = pcbList->headPtr;
|
||||||
|
|
||||||
|
// // grab how much memory is being used total, then count how big the total memory array should be
|
||||||
|
// while(wkgPtr != NULL)
|
||||||
|
// {
|
||||||
|
// // count up the total used memory within each process control block.
|
||||||
|
// for(memIterator = 0; memIterator < wkgPtr->memArraySize; memIterator++)
|
||||||
|
// {
|
||||||
|
// if(wkgPtr->allocatedMemSizes[memIterator] != -1)
|
||||||
|
// {
|
||||||
|
// // grab how much memory is used by that process
|
||||||
|
// usedMem = usedMem + wkgPtr->allocatedMemSizes[memIterator];
|
||||||
|
// }
|
||||||
|
// totalArraySize = totalArraySize + 1;
|
||||||
|
// }
|
||||||
|
// // move to the next pointer
|
||||||
|
// wkgPtr = wkgPtr->nextPtr;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// switch case for each memory code
|
// // reset the working pointer
|
||||||
switch (memCode)
|
// wkgPtr = pcbList->headPtr;
|
||||||
{
|
|
||||||
case MEMORY_INITIALIZE:
|
|
||||||
for(memIterator = 0; memIterator < singlePCB->memArraySize; memIterator++)
|
|
||||||
{
|
|
||||||
// initialize the arrays with all '-1' to 'nullify' the memory, make it easier to iterate through later
|
|
||||||
singlePCB->allocatedMemOffsets[memIterator] = -1;
|
|
||||||
singlePCB->allocatedMemSizes[memIterator] = -1;
|
|
||||||
}
|
|
||||||
if(memDisplay)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After memory initialization\n");
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MEMORY_ALLOCATE:
|
// // declare the array for the memory
|
||||||
// check if the memory allocation can happen before storing it.
|
// memorySizeArray = malloc(sizeof(int) * totalArraySize);
|
||||||
if(size <= availableMem - usedMem + 1)
|
|
||||||
{
|
|
||||||
// grab the offset and size, store it, using the allocate memory function.
|
|
||||||
subFunctionSuccess = allocMemory(singlePCB, offset, size, singlePCB->memArraySize);
|
|
||||||
usedMem = usedMem + size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// set the subfunction success to false.
|
|
||||||
subFunctionSuccess = false;
|
|
||||||
}
|
|
||||||
// if the function returns true, then it successfully did the operation, display as such.
|
|
||||||
if (memDisplay)
|
|
||||||
{
|
|
||||||
if(subFunctionSuccess)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After memory allocation\n");
|
|
||||||
printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
|
||||||
offset + size - 1, size - 1);
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After memory allocation failure\n");
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MEMORY_ACCESS:
|
// // grab the entire memory structure, so that the memory can be contiguous
|
||||||
// printf("Used memory at current: %d\n", usedMem);
|
// while (wkgPtr != NULL)
|
||||||
subFunctionSuccess = accessMemory(singlePCB, offset, size);
|
// {
|
||||||
if (memDisplay)
|
// // count up the total used memory within each process control block.
|
||||||
{
|
// for (memIterator = 0; memIterator < totalArraySize; memIterator++)
|
||||||
if (subFunctionSuccess)
|
// {
|
||||||
{
|
// // grab how much memory is used by that process
|
||||||
//
|
// memorySizeArray[memIterator] = wkgPtr->allocatedMemSizes[memIterator];
|
||||||
printf("--------------------------------------------------\n");
|
// }
|
||||||
printf("After access success\n");
|
// // move to the next pointer
|
||||||
printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
// wkgPtr = wkgPtr->nextPtr;
|
||||||
offset + size - 1, size - 1);
|
// }
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After access failure\n");
|
|
||||||
printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
|
||||||
offset + size - 1, size - 1);
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MEMORY_DEALLOCATE:
|
// // grab the size of the
|
||||||
subFunctionSuccess = deallocMemory(singlePCB, singlePCB->memArraySize);
|
// // while()
|
||||||
if (memDisplay)
|
// // {
|
||||||
{
|
// // //
|
||||||
if (subFunctionSuccess)
|
// // }
|
||||||
{
|
|
||||||
// THIS SHOULD ALWAYS HAPPEN.
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After clear process %d success\n", singlePCB->uniquePid);
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem - usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// THIS SHOULD NEVER HAPPEN.
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
printf("After clear process %d failure\n", singlePCB->uniquePid);
|
|
||||||
printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem - usedMem, currentOffset, currentSize, availableMem - 1);
|
|
||||||
printf("--------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MEMORY_CLEAR:
|
// // switch case for each memory code
|
||||||
if (memDisplay)
|
// switch (memCode)
|
||||||
{
|
// {
|
||||||
// this will happen regardless. Will always be cleaning up memory with dealloc.
|
// case MEMORY_INITIALIZE:
|
||||||
printf("--------------------------------------------------\n");
|
// for(memIterator = 0; memIterator < singlePCB->memArraySize; memIterator++)
|
||||||
printf("After memory clear\n");
|
// {
|
||||||
printf("No memory configured\n");
|
// // initialize the arrays with all '-1' to 'nullify' the memory, make it easier to iterate through later
|
||||||
printf("--------------------------------------------------\n");
|
// singlePCB->allocatedMemOffsets[memIterator] = -1;
|
||||||
}
|
// singlePCB->allocatedMemSizes[memIterator] = -1;
|
||||||
break;
|
// }
|
||||||
|
// if(memDisplay)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After memory initialization\n");
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
default:
|
// case MEMORY_ALLOCATE:
|
||||||
break;
|
// // check if the memory allocation can happen before storing it.
|
||||||
}
|
// if(size <= availableMem - usedMem + 1)
|
||||||
// clear out the dynamic array
|
// {
|
||||||
free(memorySizeArray);
|
// // grab the offset and size, store it, using the allocate memory function.
|
||||||
// return if the subfunction succeeded, if applicable
|
// subFunctionSuccess = allocMemory(singlePCB, offset, size, singlePCB->memArraySize);
|
||||||
return subFunctionSuccess;
|
// usedMem = usedMem + size;
|
||||||
}
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // set the subfunction success to false.
|
||||||
|
// subFunctionSuccess = false;
|
||||||
|
// }
|
||||||
|
// // if the function returns true, then it successfully did the operation, display as such.
|
||||||
|
// if (memDisplay)
|
||||||
|
// {
|
||||||
|
// if(subFunctionSuccess)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After memory allocation\n");
|
||||||
|
// printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
||||||
|
// offset + size - 1, size - 1);
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After memory allocation failure\n");
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case MEMORY_ACCESS:
|
||||||
|
// // printf("Used memory at current: %d\n", usedMem);
|
||||||
|
// subFunctionSuccess = accessMemory(singlePCB, offset, size);
|
||||||
|
// if (memDisplay)
|
||||||
|
// {
|
||||||
|
// if (subFunctionSuccess)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After access success\n");
|
||||||
|
// printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
||||||
|
// offset + size - 1, size - 1);
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After access failure\n");
|
||||||
|
// printf("%d [ Used, P#: %d, %d-%d ] %d\n", offset - offset, singlePCB->uniquePid, offset,
|
||||||
|
// offset + size - 1, size - 1);
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case MEMORY_DEALLOCATE:
|
||||||
|
// subFunctionSuccess = deallocMemory(singlePCB, singlePCB->memArraySize);
|
||||||
|
// if (memDisplay)
|
||||||
|
// {
|
||||||
|
// if (subFunctionSuccess)
|
||||||
|
// {
|
||||||
|
// // THIS SHOULD ALWAYS HAPPEN.
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After clear process %d success\n", singlePCB->uniquePid);
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem - usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // THIS SHOULD NEVER HAPPEN.
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After clear process %d failure\n", singlePCB->uniquePid);
|
||||||
|
// printf("%d [ Open, P#: x, %d-%d ] %d\n", usedMem - usedMem, currentOffset, currentSize, availableMem - 1);
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case MEMORY_CLEAR:
|
||||||
|
// if (memDisplay)
|
||||||
|
// {
|
||||||
|
// // this will happen regardless. Will always be cleaning up memory with dealloc.
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// printf("After memory clear\n");
|
||||||
|
// printf("No memory configured\n");
|
||||||
|
// printf("--------------------------------------------------\n");
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// // clear out the dynamic array
|
||||||
|
// free(memorySizeArray);
|
||||||
|
// // return if the subfunction succeeded, if applicable
|
||||||
|
// return subFunctionSuccess;
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Name: runCPU
|
Name: runCPU
|
||||||
|
|
@ -910,15 +920,17 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
||||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||||
logOutput(configPtr, processOutput, false, logList);
|
logOutput(configPtr, processOutput, false, logList);
|
||||||
// run the memory manager in allocate mode
|
// run the memory manager in allocate mode
|
||||||
memManagerSuccess = memManager(pcbList, MEMORY_ALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
// printf("Memory Offset: %d\n", intArg);
|
||||||
if(!memManagerSuccess)
|
// printf("Memory Size: %d\n", intArgTwo);
|
||||||
{
|
// memManagerSuccess = memManager(pcbList, MEMORY_ALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
||||||
//
|
// if(!memManagerSuccess)
|
||||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
// {
|
||||||
sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
// //
|
||||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
// timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||||
logOutput(configPtr, processOutput, false, logList);
|
// sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
||||||
}
|
// singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||||
|
// logOutput(configPtr, processOutput, false, logList);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else if(compareString(argument, "access") == EQUIV)
|
else if(compareString(argument, "access") == EQUIV)
|
||||||
{
|
{
|
||||||
|
|
@ -927,15 +939,15 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
||||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||||
logOutput(configPtr, processOutput, false, logList);
|
logOutput(configPtr, processOutput, false, logList);
|
||||||
// run the memory manager in access mode
|
// run the memory manager in access mode
|
||||||
memManagerSuccess = memManager(pcbList, MEMORY_ACCESS, intArg, intArgTwo, configPtr, singlePCB);
|
// memManagerSuccess = memManager(pcbList, MEMORY_ACCESS, intArg, intArgTwo, configPtr, singlePCB);
|
||||||
if (!memManagerSuccess)
|
// if (!memManagerSuccess)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
// timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||||
sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
// sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
||||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
// singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||||
logOutput(configPtr, processOutput, false, logList);
|
// logOutput(configPtr, processOutput, false, logList);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
workingMeta = workingMeta->nextNode;
|
workingMeta = workingMeta->nextNode;
|
||||||
|
|
@ -971,7 +983,7 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
||||||
logOutput(configPtr, processOutput, false, logList);
|
logOutput(configPtr, processOutput, false, logList);
|
||||||
}
|
}
|
||||||
// deallocate the memory for the process
|
// deallocate the memory for the process
|
||||||
memManager(pcbList, MEMORY_DEALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
// memManager(pcbList, MEMORY_DEALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1066,7 +1078,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
||||||
currentPid = scheduleProcess(pcbList, configPtr, loggingList);
|
currentPid = scheduleProcess(pcbList, configPtr, loggingList);
|
||||||
|
|
||||||
// initialize memory with the memManager
|
// initialize memory with the memManager
|
||||||
memManager(pcbList, MEMORY_INITIALIZE, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
// memManager(pcbList, MEMORY_INITIALIZE, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
||||||
|
|
||||||
// loop until current process is hit
|
// loop until current process is hit
|
||||||
for(processIterator = 0; processIterator < processCount; processIterator++)
|
for(processIterator = 0; processIterator < processCount; processIterator++)
|
||||||
|
|
@ -1114,7 +1126,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
||||||
}
|
}
|
||||||
pthread_join(cpuThread, NULL);
|
pthread_join(cpuThread, NULL);
|
||||||
// deallocate all the memory for each process.
|
// deallocate all the memory for each process.
|
||||||
memManager(pcbList, MEMORY_CLEAR, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
// memManager(pcbList, MEMORY_CLEAR, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
||||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||||
sprintf(simulatorOutput, "%f, OS: System Stop\n", timeDigits);
|
sprintf(simulatorOutput, "%f, OS: System Stop\n", timeDigits);
|
||||||
logOutput(configPtr, simulatorOutput, false, loggingList);
|
logOutput(configPtr, simulatorOutput, false, loggingList);
|
||||||
|
|
|
||||||
|
|
@ -301,8 +301,8 @@ Device Input/Device: none
|
||||||
Device Output/Device: none
|
Device Output/Device: none
|
||||||
Dependencies: ???
|
Dependencies: ???
|
||||||
*/
|
*/
|
||||||
bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
// bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
||||||
ProcessControlBlock *singlePCB);
|
// ProcessControlBlock *singlePCB);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Name: runCPU
|
Name: runCPU
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue