isn't working on my VM for some reason. will try on other devices.

This commit is contained in:
Charles Descamps 2024-04-21 16:12:29 -07:00
parent a7506f82c8
commit 2c2f2cf848
5 changed files with 616 additions and 93 deletions

View file

@ -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