isn't working on my VM for some reason. will try on other devices.
This commit is contained in:
parent
a7506f82c8
commit
2c2f2cf848
5 changed files with 616 additions and 93 deletions
BIN
Sim03/sim03
Normal file → Executable file
BIN
Sim03/sim03
Normal file → Executable file
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
0.000000, OS: Simulator start
|
||||
BIN
Sim04/sim04
Normal file → Executable file
BIN
Sim04/sim04
Normal file → Executable file
Binary file not shown.
|
|
@ -17,6 +17,32 @@ bool accessMemory(ProcessControlBlock *singlePCB, int offset, int size)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: addLog
|
||||
Process: allocates the memory for the log, ...
|
||||
Function Input/Parameters: source log (logFile)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: filled PCB (logFile *)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFile *addLog(const logFile source)
|
||||
{
|
||||
// declare a pointer to working node
|
||||
logFile *workingNode;
|
||||
// make some space that the pointer is pointing to
|
||||
workingNode = malloc(sizeof(logFile));
|
||||
// make some space for the string data
|
||||
// workingNode->stringData = malloc(sizeof(source.stringData));
|
||||
// get each value from the source, and set their values
|
||||
copyString(workingNode->stringData, source.stringData);
|
||||
// make sure to set the next pointer to NULL!
|
||||
workingNode->nextPtr = NULL;
|
||||
// return workingNode
|
||||
return workingNode;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: addProcess
|
||||
Process: allocates the memory for the pcb, grabs the data from the created PCB,
|
||||
|
|
@ -77,6 +103,27 @@ bool allocMemory(ProcessControlBlock *singlePCB, int offset, int size, int array
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: createFileLogList
|
||||
Process: initializes the logging file struct
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: head pointer to the logfile struct
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFileLL *createFileLogList()
|
||||
{
|
||||
// allocate and create the logFileLL using malloc and size of
|
||||
logFileLL *headBlock;
|
||||
headBlock = malloc(sizeof(logFileLL));
|
||||
// set the head pointer to NULL
|
||||
headBlock->headPtr = NULL;
|
||||
// return headBlock
|
||||
return headBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: createProcessList
|
||||
Process: reads through the opcode struct to fill out the linked list of PCBs
|
||||
|
|
@ -122,6 +169,26 @@ bool deallocMemory(ProcessControlBlock *singlePCB, int arraySize)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: destroyFileLogList
|
||||
Process: deallocates memory used for the linked list struct
|
||||
Function Input/Parameters: head pointer to linked list (logFileLL *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper, ???
|
||||
*/
|
||||
logFileLL *destroyFileLogList(logFileLL *linkedListPtr)
|
||||
{
|
||||
// call the first destroyFileLogHelper
|
||||
destroyFileLogHelper(linkedListPtr->headPtr);
|
||||
// free the rest of the struct
|
||||
free(linkedListPtr);
|
||||
// return null
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: destroyProcessList
|
||||
Process: deallocates memory used for the linked list struct
|
||||
|
|
@ -142,6 +209,30 @@ ProcessControlBlockLL *destroyProcessList(ProcessControlBlockLL *linkedListPtr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: destroyFileLogHelper
|
||||
Process: recursively clears the logfile linked list struct, freeing the struct
|
||||
Function Input/Parameters: head pointer to logfile list (logFile *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper(recursively), ???
|
||||
*/
|
||||
logFile *destroyFileLogHelper(logFile *nodePtr)
|
||||
{
|
||||
// check to see if the pointer is NOT null
|
||||
if (nodePtr != NULL)
|
||||
{
|
||||
// if not null, move to the next pointer (recurse)
|
||||
nodePtr->nextPtr = destroyFileLogHelper(nodePtr->nextPtr);
|
||||
}
|
||||
// free the 'parent' node
|
||||
free(nodePtr);
|
||||
// return null
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: destroyProcessListHelper
|
||||
Process: recursively clears the PCB linked list struct, freeing the struct
|
||||
|
|
@ -384,48 +475,65 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: fprintf, ???
|
||||
*/
|
||||
void logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd)
|
||||
logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFileLL *logPtr)
|
||||
{
|
||||
if(configPtr->logToCode == LOGTO_BOTH_CODE)
|
||||
logFile toLog;
|
||||
logFile *logStrPtr;
|
||||
logFile *wkgLogPtr;
|
||||
logFile *prevWkgLogPtr;
|
||||
wkgLogPtr = logPtr->headPtr;
|
||||
// close the file, if at the end.
|
||||
if (isEnd)
|
||||
{
|
||||
//
|
||||
if (configPtr->logToCode == LOGTO_FILE_CODE)
|
||||
{
|
||||
//
|
||||
printf("\nSimulator has output to the file '%s'.\n", configPtr->logToFileName);
|
||||
}
|
||||
FILE *fileWritePtr;
|
||||
fileWritePtr = fopen(configPtr->logToFileName, "w+");
|
||||
fileWritePtr = fopen(configPtr->logToFileName, "w");
|
||||
if (fileWritePtr != NULL)
|
||||
{
|
||||
fprintf(fileWritePtr, "%s", logStr);
|
||||
fprintf(stdout, "%s", logStr);
|
||||
while (wkgLogPtr != NULL)
|
||||
{
|
||||
fprintf(fileWritePtr, "%s", wkgLogPtr->stringData);
|
||||
wkgLogPtr = wkgLogPtr->nextPtr;
|
||||
}
|
||||
}
|
||||
// no return, void
|
||||
// close the file, if at the end.
|
||||
if (isEnd)
|
||||
{
|
||||
fclose(fileWritePtr);
|
||||
}
|
||||
// fclose(fileWritePtr);
|
||||
}
|
||||
else if(configPtr->logToCode == LOGTO_FILE_CODE)
|
||||
{
|
||||
//
|
||||
printf("\nSimulator will output to a file.\n");
|
||||
FILE *fileWritePtr;
|
||||
fileWritePtr = fopen(configPtr->logToFileName, "w+");
|
||||
if (fileWritePtr != NULL)
|
||||
{
|
||||
fprintf(fileWritePtr, "%s", logStr);
|
||||
}
|
||||
// no return, void
|
||||
// close the file, if at the end.
|
||||
if (isEnd)
|
||||
{
|
||||
fclose(fileWritePtr);
|
||||
}
|
||||
// fclose(fileWritePtr);
|
||||
fclose(fileWritePtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "%s", logStr);
|
||||
// need to add the string to the end of the LL.
|
||||
if(configPtr->logToCode == LOGTO_BOTH_CODE || configPtr->logToCode == LOGTO_FILE_CODE)
|
||||
{
|
||||
//
|
||||
copyString(toLog.stringData, logStr);
|
||||
toLog.nextPtr = NULL;
|
||||
while (wkgLogPtr != NULL)
|
||||
{
|
||||
prevWkgLogPtr = wkgLogPtr;
|
||||
wkgLogPtr = wkgLogPtr->nextPtr;
|
||||
}
|
||||
if (logPtr->headPtr == NULL)
|
||||
{
|
||||
logPtr->headPtr = addLog(toLog);
|
||||
}
|
||||
if (wkgLogPtr == NULL)
|
||||
{
|
||||
logStrPtr = addLog(toLog);
|
||||
// prevWkgLogPtr->nextPtr = addLog(toLog);
|
||||
// prevWkgLogPtr->nextPtr = logStrPtr;
|
||||
wkgLogPtr = logStrPtr;
|
||||
}
|
||||
}
|
||||
if (configPtr->logToCode == LOGTO_BOTH_CODE || configPtr->logToCode == LOGTO_MONITOR_CODE)
|
||||
{
|
||||
//
|
||||
fprintf(stdout, "%s", logStr);
|
||||
}
|
||||
}
|
||||
return logPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -636,8 +744,8 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
||||
int processId, ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod)
|
||||
void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList)
|
||||
{
|
||||
double timeDigits;
|
||||
char timeStringy[MAX_STR_LEN];
|
||||
|
|
@ -655,13 +763,13 @@ void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr
|
|||
cpuTime = intArg * configPtr->procCycleRate;
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(cpuOutput, "%f, Process: %d, %s %s operation start\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, cpuOutput, false);
|
||||
logOutput(configPtr, cpuOutput, false, logList);
|
||||
// run timer for intArg * procCycleRate
|
||||
pthread_create(&cpuThread, NULL, runTimer, (void *)cpuTimePtr);
|
||||
pthread_join(cpuThread, NULL);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(cpuOutput, "%f, Process: %d, %s %s operation end\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, cpuOutput, false);
|
||||
logOutput(configPtr, cpuOutput, false, logList);
|
||||
// pthread_exit(NULL);
|
||||
break;
|
||||
|
||||
|
|
@ -669,13 +777,13 @@ void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr
|
|||
cpuTime = intArg * configPtr->procCycleRate;
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(cpuOutput, "%f, Process: %d, %s %s operation start\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, cpuOutput, false);
|
||||
logOutput(configPtr, cpuOutput, false, logList);
|
||||
// run timer for intArg * procCycleRate
|
||||
pthread_create(&cpuThread, NULL, runTimer, (void *)cpuTimePtr);
|
||||
pthread_join(cpuThread, NULL);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(cpuOutput, "%f, Process: %d, %s %s operation end\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, cpuOutput, false);
|
||||
logOutput(configPtr, cpuOutput, false, logList);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -694,8 +802,8 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
||||
int processId, ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod)
|
||||
void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList)
|
||||
{
|
||||
double timeDigits;
|
||||
char timeStringy[MAX_STR_LEN];
|
||||
|
|
@ -710,12 +818,12 @@ void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
|||
ioTime = intArg * configPtr->ioCycleRate;
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(ioOutput, "%f, Process: %d, %s %s operation start\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, ioOutput, false);
|
||||
logOutput(configPtr, ioOutput, false, logList);
|
||||
pthread_create(&ioThread, NULL, runTimer, (void *)ioTimePtr);
|
||||
pthread_join(ioThread, NULL);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(ioOutput, "%f, Process: %d, %s %s operation end\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, ioOutput, false);
|
||||
logOutput(configPtr, ioOutput, false, logList);
|
||||
break;
|
||||
|
||||
case PREEMPTIVE_CODE:
|
||||
|
|
@ -724,11 +832,11 @@ void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
|||
ioTime = intArg * configPtr->ioCycleRate;
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(ioOutput, "%f, Process: %d, %s %s operation start\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, ioOutput, false);
|
||||
logOutput(configPtr, ioOutput, false, logList);
|
||||
pthread_create(&ioThread, NULL, runTimer, (void *)ioTimePtr);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(ioOutput, "%f, Process: %d, %s %s operation end\n", timeDigits, processId, command, argument);
|
||||
logOutput(configPtr, ioOutput, false);
|
||||
logOutput(configPtr, ioOutput, false, logList);
|
||||
// pthread_join(ioThread, NULL); // not sure if this will be needed...
|
||||
// pthread_exit(NULL); // this may be needed if pthread_join doesn't produce expected results.
|
||||
// call the interruptManager here, with the IO Return code.
|
||||
|
|
@ -751,8 +859,8 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: accessTimer, compareString, runCPU, runIO, ???
|
||||
*/
|
||||
void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, ProcessControlBlockLL *pcbList,
|
||||
ConfigDataCodes schedMethod)
|
||||
void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, ProcessControlBlockLL *pcbList,
|
||||
ConfigDataCodes schedMethod, logFileLL *logList)
|
||||
{
|
||||
double timeDigits;
|
||||
// run over the entire process, running the CPU when a CPU cycle comes up
|
||||
|
|
@ -781,13 +889,13 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
{
|
||||
// run the CPU for the required amount of time.
|
||||
runCPU(workingMeta->command, workingMeta->strArg1, workingMeta->intArg2, configPtr, singlePCB->uniquePid,
|
||||
singlePCB, schedMethod);
|
||||
singlePCB, schedMethod, logList);
|
||||
}
|
||||
if(compareString(command, "dev") == EQUIV)
|
||||
{
|
||||
// run IO operations for the required amount of time.
|
||||
runIO(workingMeta->command, workingMeta->strArg1, workingMeta->intArg2, configPtr, singlePCB->uniquePid,
|
||||
singlePCB, schedMethod);
|
||||
singlePCB, schedMethod, logList);
|
||||
}
|
||||
if(compareString(command, "mem") == EQUIV)
|
||||
{
|
||||
|
|
@ -797,7 +905,7 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "%f, Process: %d, %s %s request (%d, %d)\n", timeDigits,
|
||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
// run the memory manager in allocate mode
|
||||
memManagerSuccess = memManager(pcbList, MEMORY_ALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
||||
if(!memManagerSuccess)
|
||||
|
|
@ -806,7 +914,7 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
}
|
||||
}
|
||||
else if(compareString(argument, "access") == EQUIV)
|
||||
|
|
@ -814,7 +922,7 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "%f, Process: %d, %s %s request (%d, %d)\n", timeDigits,
|
||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
// run the memory manager in access mode
|
||||
memManagerSuccess = memManager(pcbList, MEMORY_ACCESS, intArg, intArgTwo, configPtr, singlePCB);
|
||||
if (!memManagerSuccess)
|
||||
|
|
@ -823,7 +931,7 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "%f, Process: %d, failed %s %s request (%d, %d)\n", timeDigits,
|
||||
singlePCB->uniquePid, command, argument, intArg, intArgTwo);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -850,14 +958,14 @@ void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, Proce
|
|||
//
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "\n%f, OS: Process %d ended\n", timeDigits, singlePCB->uniquePid);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(processOutput, "\n%f, OS: Segmentation Fault, Process %d ended\n", timeDigits, singlePCB->uniquePid);
|
||||
logOutput(configPtr, processOutput, false);
|
||||
logOutput(configPtr, processOutput, false, logList);
|
||||
}
|
||||
// deallocate the memory for the process
|
||||
memManager(pcbList, MEMORY_DEALLOCATE, intArg, intArgTwo, configPtr, singlePCB);
|
||||
|
|
@ -883,6 +991,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
// need a variable for headPointer to point
|
||||
ProcessControlBlockLL *pcbList;
|
||||
ProcessControlBlock *pcbPtr;
|
||||
logFileLL *loggingList;
|
||||
// string variable for nextCode, temp unused
|
||||
// char *nextCode;
|
||||
// string variable for the timer stuff
|
||||
|
|
@ -895,6 +1004,16 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
int memoryOffset = 0;
|
||||
int memorySize = 1;
|
||||
|
||||
// create the file list with createFileLogList, store the pointed to address
|
||||
loggingList = createFileLogList();
|
||||
|
||||
// check to see if in file mode, and print, 'Sim will output to file'
|
||||
if (configPtr->logToCode == LOGTO_FILE_CODE)
|
||||
{
|
||||
//
|
||||
printf("Simulator will output to a file. (Please be patient...)\n");
|
||||
}
|
||||
|
||||
if (schedulingMethod == CPU_SCHED_FCFS_P_CODE ||
|
||||
schedulingMethod == CPU_SCHED_RR_P_CODE ||
|
||||
schedulingMethod == CPU_SCHED_SRTF_P_CODE)
|
||||
|
|
@ -912,7 +1031,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
// Operating System start timer goes here, log it.
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(simulatorOutput, "%f, OS: Simulator start\n", timeDigits);
|
||||
logOutput(configPtr, simulatorOutput, false);
|
||||
logOutput(configPtr, simulatorOutput, false, loggingList);
|
||||
// int variable for process to run
|
||||
int currentPid;
|
||||
// create the process list with createProcessList, store the pointed to address
|
||||
|
|
@ -941,7 +1060,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
int *processTimeLeftPtr = &processTimeLeft;
|
||||
|
||||
// set the current process id to the first scheduled process
|
||||
currentPid = scheduleProcess(pcbList, configPtr);
|
||||
currentPid = scheduleProcess(pcbList, configPtr, loggingList);
|
||||
|
||||
// initialize memory with the memManager
|
||||
memManager(pcbList, MEMORY_INITIALIZE, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
||||
|
|
@ -961,10 +1080,10 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(simulatorOutput, "%f, OS: Process %d set to RUNNING state from READY state\n\n", timeDigits,
|
||||
pcbPtr->uniquePid);
|
||||
logOutput(configPtr, simulatorOutput, false);
|
||||
logOutput(configPtr, simulatorOutput, false, loggingList);
|
||||
pthread_t runThread;
|
||||
pthread_create(&runThread, NULL, runTimer, (void *)processTimeLeftPtr);
|
||||
runProcess(pcbPtr, configPtr, pcbList, schedulingMethod);
|
||||
runProcess(pcbPtr, configPtr, pcbList, schedulingMethod, loggingList);
|
||||
switch (schedulingMethod)
|
||||
{
|
||||
case NON_PREEMPTIVE_CODE:
|
||||
|
|
@ -972,7 +1091,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(simulatorOutput, "%f, OS: Process %d set to TERMINATED state from RUNNING state\n\n", timeDigits,
|
||||
pcbPtr->uniquePid);
|
||||
logOutput(configPtr, simulatorOutput, false);
|
||||
logOutput(configPtr, simulatorOutput, false, loggingList);
|
||||
// this assumes that the processes finish executing all the way though.
|
||||
pcbPtr->process_state = PROCESS_STATE_TERMINATED;
|
||||
break;
|
||||
|
|
@ -987,7 +1106,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
processTimeLeftPtr = &processTimeLeft;
|
||||
pcbPtr = pcbPtr->nextPtr;
|
||||
}
|
||||
currentPid = scheduleProcess(pcbList, configPtr);
|
||||
currentPid = scheduleProcess(pcbList, configPtr, loggingList);
|
||||
pcbPtr = pcbList->headPtr;
|
||||
}
|
||||
pthread_join(cpuThread, NULL);
|
||||
|
|
@ -995,14 +1114,13 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
|||
memManager(pcbList, MEMORY_CLEAR, memoryOffset, memorySize, configPtr, pcbList->headPtr);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(simulatorOutput, "%f, OS: System Stop\n", timeDigits);
|
||||
logOutput(configPtr, simulatorOutput, false);
|
||||
logOutput(configPtr, simulatorOutput, false, loggingList);
|
||||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(simulatorOutput, "%f, OS: Simulation End\n", timeDigits);
|
||||
logOutput(configPtr, simulatorOutput, true);
|
||||
logOutput(configPtr, simulatorOutput, true, loggingList);
|
||||
// deallocate the process list with destroyProcessList
|
||||
destroyProcessList(pcbList);
|
||||
// once complete, log the output to FILE if required
|
||||
logOutput(configPtr, "", true);
|
||||
destroyFileLogList(loggingList);
|
||||
// pthread_exit(NULL); // this line seems to make the program execution stop short... no warning either
|
||||
// void function, no return.
|
||||
}
|
||||
|
|
@ -1018,7 +1136,7 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: sprintf, logOutput, ???
|
||||
*/
|
||||
int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr)
|
||||
int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr, logFileLL *logList)
|
||||
{
|
||||
double timeDigits;
|
||||
ProcessControlBlock *wkgPtr;
|
||||
|
|
@ -1063,7 +1181,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d set to READY state from NEW state\n", timeDigits,
|
||||
wkgPtr->uniquePid);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
// move to the next pointer
|
||||
wkgPtr = wkgPtr->nextPtr;
|
||||
|
|
@ -1080,7 +1198,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d selected with %.0f ms remaining\n", timeDigits,
|
||||
wkgPtr->uniquePid, wkgPtr->timeLeft);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
returnPid = wkgPtr->uniquePid;
|
||||
}
|
||||
// move to next pointer
|
||||
|
|
@ -1105,7 +1223,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d set to READY state from NEW state\n", timeDigits,
|
||||
wkgPtr->uniquePid);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
// move to the next pointer
|
||||
wkgPtr = wkgPtr->nextPtr;
|
||||
|
|
@ -1124,7 +1242,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d selected with %.0f ms remaining\n", timeDigits,
|
||||
wkgPtr->uniquePid, wkgPtr->timeLeft);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
returnPid = wkgPtr->uniquePid;
|
||||
}
|
||||
// move to next pointer
|
||||
|
|
@ -1156,7 +1274,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d set to READY state from NEW state\n", timeDigits,
|
||||
wkgPtr->uniquePid);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
// move to the next pointer
|
||||
wkgPtr = wkgPtr->nextPtr;
|
||||
|
|
@ -1209,7 +1327,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d selected with %.0f ms remaining\n", timeDigits,
|
||||
shortestJobProcNum, (double)shortestJob);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
returnPid = shortestJobProcNum;
|
||||
break;
|
||||
|
|
@ -1228,7 +1346,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d set to READY state from NEW state\n", timeDigits,
|
||||
wkgPtr->uniquePid);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
// move to the next pointer
|
||||
wkgPtr = wkgPtr->nextPtr;
|
||||
|
|
@ -1283,7 +1401,7 @@ int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPt
|
|||
timeDigits = accessTimer(LAP_TIMER, timeStringy);
|
||||
sprintf(loggingStr, "%f, OS: Process %d selected with %.0f ms remaining\n", timeDigits,
|
||||
shortestJobProcNum, (double)shortestJob);
|
||||
logOutput(configPtr, loggingStr, false);
|
||||
logOutput(configPtr, loggingStr, false, logList);
|
||||
}
|
||||
returnPid = shortestJobProcNum;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,19 @@ typedef enum{
|
|||
CLEAR_INTERRUPT
|
||||
} INTERRUPT_ROUTINE;
|
||||
|
||||
typedef struct logFileStruct
|
||||
{
|
||||
char stringData[HUGE_STR_LEN];
|
||||
// connect to the next process control block here
|
||||
struct logFileStruct *nextPtr;
|
||||
} logFile;
|
||||
|
||||
typedef struct logFileLLStruct
|
||||
{
|
||||
// holds the head ptr for PCBs
|
||||
logFile *headPtr;
|
||||
} logFileLL;
|
||||
|
||||
typedef struct ProcessControlBlockStruct
|
||||
{
|
||||
int uniquePid;
|
||||
|
|
@ -90,6 +103,31 @@ Device Output/Device: none
|
|||
Dependencies: ???
|
||||
*/
|
||||
|
||||
/*
|
||||
Name: accessMemory
|
||||
Process: checks that the memory is between the offset and the size.
|
||||
checks that the memory is ???
|
||||
Function Input/Parameters: source PCB (ProcessControlBlock *), offset (int), size (int)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: boolean to indicate success or failure of accessed memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool accessMemory(ProcessControlBlock *singlePCB, int offset, int size);
|
||||
|
||||
/*
|
||||
Name: addLog
|
||||
Process: allocates the memory for the log, ...
|
||||
Function Input/Parameters: source log (logFile)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: filled PCB (logFile *)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFile *addLog(const logFile source);
|
||||
|
||||
/*
|
||||
Name: addProcess
|
||||
Process: allocates the memory for the pcb, grabs the data from the created PCB,
|
||||
|
|
@ -103,9 +141,33 @@ Dependencies: malloc, sizeof, ???
|
|||
*/
|
||||
ProcessControlBlock *addProcess(const ProcessControlBlock source);
|
||||
|
||||
/*
|
||||
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: boolean to indicate success or failure of allocated memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool allocMemory(ProcessControlBlock *singlePCB, int offset, int size, int arraySize);
|
||||
|
||||
/*
|
||||
Name: createFileLogList
|
||||
Process: initializes the logging file struct
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: head pointer to the logfile struct
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFileLL *createFileLogList();
|
||||
|
||||
/*
|
||||
Name: createProcessList
|
||||
Process: initializes head pointer to the PCBs
|
||||
Process: reads through the opcode struct to fill out the linked list of PCBs
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: head pointer to the PCBs
|
||||
|
|
@ -115,6 +177,30 @@ Dependencies: malloc, sizeof, ???
|
|||
*/
|
||||
ProcessControlBlockLL *createProcessList();
|
||||
|
||||
/*
|
||||
Name: deallocMemory
|
||||
Process: 'deallocates' memory within the PCB, removes every offset and size within it's PCB
|
||||
Function Input/Parameters: source PCB (ProcessControlBlock *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: boolean to indicate success or failure of allocated memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool deallocMemory(ProcessControlBlock *singlePCB, int arraySize);
|
||||
|
||||
/*
|
||||
Name: destroyFileLogList
|
||||
Process: deallocates memory used for the linked list struct
|
||||
Function Input/Parameters: head pointer to linked list (logFileLL *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper, ???
|
||||
*/
|
||||
logFileLL *destroyFileLogList(logFileLL *linkedListPtr);
|
||||
|
||||
/*
|
||||
Name: destroyProcessList
|
||||
Process: deallocates memory used for the linked list struct
|
||||
|
|
@ -127,6 +213,18 @@ Dependencies: free, destroyProcessListHelper, ???
|
|||
*/
|
||||
ProcessControlBlockLL *destroyProcessList(ProcessControlBlockLL *linkedListPtr);
|
||||
|
||||
/*
|
||||
Name: destroyFileLogHelper
|
||||
Process: recursively clears the logfile linked list struct, freeing the struct
|
||||
Function Input/Parameters: head pointer to logfile list (logFile *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper(recursively), ???
|
||||
*/
|
||||
logFile *destroyFileLogHelper(logFile *nodePtr);
|
||||
|
||||
/*
|
||||
Name: destroyProcessListHelper
|
||||
Process: recursively clears the PCB linked list struct, freeing the struct
|
||||
|
|
@ -150,8 +248,7 @@ Device Input/Device: none
|
|||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
ProcessControlBlockLL *fillProcessList(ConfigDataType *configPtr, OpCodeType *metadataPtr,
|
||||
ProcessControlBlockLL *headPointer);
|
||||
ProcessControlBlockLL *fillProcessList(ConfigDataType *configPtr, OpCodeType *metadataPtr, ProcessControlBlockLL *headPointer);
|
||||
|
||||
/*
|
||||
Name: findMin
|
||||
|
|
@ -165,19 +262,47 @@ Dependencies: none
|
|||
*/
|
||||
int findMin(int one, int another);
|
||||
|
||||
/*
|
||||
Name: interruptManager
|
||||
Process: does the managing of interrupts for the program
|
||||
Function Input/Parameters: ???
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: ???
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
bool interruptManager(ConfigDataType *configPtr, ProcessControlBlock *singlePCB, INTERRUPT_ROUTINE interruptRequest);
|
||||
|
||||
/*
|
||||
Name: logOutput
|
||||
Process: Takes in a string, and then outputs it to monitor AND/OR file
|
||||
Function Input/Parameters: string (char *), file pointer (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, ???
|
||||
Dependencies: fprintf, ???
|
||||
*/
|
||||
void logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd);
|
||||
logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFileLL *logPtr);
|
||||
|
||||
/*
|
||||
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: boolean for success or failure of memory management
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
||||
ProcessControlBlock *singlePCB);
|
||||
|
||||
/*
|
||||
Name: runCPU
|
||||
|
|
@ -187,10 +312,10 @@ Function Output/Parameters: none
|
|||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
||||
int processId, ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod);
|
||||
void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
Name: runIO
|
||||
|
|
@ -200,33 +325,312 @@ Function Output/Parameters: none
|
|||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr,
|
||||
int processId, ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod);
|
||||
void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
Name: runSim
|
||||
Process: primary simulation driver
|
||||
Function Input/Parameters: configuration data (ConfigDataType *),
|
||||
metadata (OpCodeType *)
|
||||
Name: runProcess
|
||||
Process: runs the process that was selected
|
||||
Function Input/Parameters: ???
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: accessTimer, compareString, runCPU, runIO, ???
|
||||
*/
|
||||
void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, ProcessControlBlockLL *pcbList,
|
||||
ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
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: pthreads, accessTimer, sprintf, logOutput, runProcess, destroyProcessList, ???
|
||||
*/
|
||||
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 Input/Parameters: head pointer of PCB List (ProcessControlBlockLL *),
|
||||
configuration data (ConfigDataType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: sprintf, logOutput, ???
|
||||
*/
|
||||
int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr, logFileLL *logList); /*
|
||||
Name: accessMemory
|
||||
Process: checks that the memory is between the offset and the size.
|
||||
checks that the memory is ???
|
||||
Function Input/Parameters: source PCB (ProcessControlBlock *), offset (int), size (int)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: boolean to indicate success or failure of accessed memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool accessMemory(ProcessControlBlock *singlePCB, int offset, int size);
|
||||
|
||||
/*
|
||||
Name: addLog
|
||||
Process: allocates the memory for the log, ...
|
||||
Function Input/Parameters: source log (logFile)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: filled PCB (logFile *)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFile *addLog(const logFile source);
|
||||
|
||||
/*
|
||||
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: 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: boolean to indicate success or failure of allocated memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr);
|
||||
bool allocMemory(ProcessControlBlock *singlePCB, int offset, int size, int arraySize);
|
||||
|
||||
#endif // SIMULATORX
|
||||
/*
|
||||
Name: createFileLogList
|
||||
Process: initializes the logging file struct
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: head pointer to the logfile struct
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, sizeof, ???
|
||||
*/
|
||||
logFileLL *createFileLogList();
|
||||
|
||||
/*
|
||||
Name: createProcessList
|
||||
Process: reads through the opcode struct to fill out the linked list of 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: deallocMemory
|
||||
Process: 'deallocates' memory within the PCB, removes every offset and size within it's PCB
|
||||
Function Input/Parameters: source PCB (ProcessControlBlock *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: boolean to indicate success or failure of allocated memory
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool deallocMemory(ProcessControlBlock *singlePCB, int arraySize);
|
||||
|
||||
/*
|
||||
Name: destroyFileLogList
|
||||
Process: deallocates memory used for the linked list struct
|
||||
Function Input/Parameters: head pointer to linked list (logFileLL *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper, ???
|
||||
*/
|
||||
logFileLL *destroyFileLogList(logFileLL *linkedListPtr);
|
||||
|
||||
/*
|
||||
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: destroyFileLogHelper
|
||||
Process: recursively clears the logfile linked list struct, freeing the struct
|
||||
Function Input/Parameters: head pointer to logfile list (logFile *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: NULL
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: free, destroyFileLogHelper(recursively), ???
|
||||
*/
|
||||
logFile *destroyFileLogHelper(logFile *nodePtr);
|
||||
|
||||
/*
|
||||
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: interruptManager
|
||||
Process: does the managing of interrupts for the program
|
||||
Function Input/Parameters: ???
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: ???
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
bool interruptManager(ConfigDataType *configPtr, ProcessControlBlock *singlePCB, INTERRUPT_ROUTINE interruptRequest);
|
||||
|
||||
/*
|
||||
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: fprintf, ???
|
||||
*/
|
||||
logFileLL *logOutput(ConfigDataType *configPtr, char *logStr, bool isEnd, logFileLL *logPtr);
|
||||
|
||||
/*
|
||||
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: boolean for success or failure of memory management
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
bool memManager(ProcessControlBlockLL *pcbList, MEMORY_SIGNALS memCode, int offset, int size, ConfigDataType *configPtr,
|
||||
ProcessControlBlock *singlePCB);
|
||||
|
||||
/*
|
||||
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: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
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: pthreads, sprintf, logOutput, ???
|
||||
*/
|
||||
void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr, int processId,
|
||||
ProcessControlBlock *singlePCB, ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
Name: runProcess
|
||||
Process: runs the process that was selected
|
||||
Function Input/Parameters: ???
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: accessTimer, compareString, runCPU, runIO, ???
|
||||
*/
|
||||
void runProcess(ProcessControlBlock *singlePCB, ConfigDataType *configPtr, ProcessControlBlockLL *pcbList,
|
||||
ConfigDataCodes schedMethod, logFileLL *logList);
|
||||
|
||||
/*
|
||||
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: pthreads, accessTimer, sprintf, logOutput, runProcess, destroyProcessList, ???
|
||||
*/
|
||||
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 *),
|
||||
configuration data (ConfigDataType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: sprintf, logOutput, ???
|
||||
*/
|
||||
int scheduleProcess(ProcessControlBlockLL *headPointer, ConfigDataType *configPtr, logFileLL *logList);
|
||||
|
||||
#endif // SIMULATORX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue