Working on changes, maybe working?
This commit is contained in:
parent
7b837ddf86
commit
3af7742043
8 changed files with 127 additions and 74 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -67,4 +67,5 @@ _deps
|
||||||
|
|
||||||
# Text Docs
|
# Text Docs
|
||||||
*.txt
|
*.txt
|
||||||
|
*.xlsx
|
||||||
|
*.docx
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,24 @@
|
||||||
const int SUBSTRING_NOT_FOUND = 0;
|
const int SUBSTRING_NOT_FOUND = 0;
|
||||||
|
|
||||||
// list of utils:
|
// list of utils:
|
||||||
// string length
|
// string length
|
||||||
// getStringLength
|
// getStringLength
|
||||||
// string copy
|
// string copy
|
||||||
// copyString
|
// copyString
|
||||||
// string concatenate
|
// string concatenate
|
||||||
// catString
|
// catString
|
||||||
// string compare (<, >, =)
|
// string compare (<, >, =)
|
||||||
// compareString
|
// compareString
|
||||||
// string substring get
|
// string substring get
|
||||||
// getSubString
|
// getSubString
|
||||||
// string substring find
|
// string substring find
|
||||||
// findSubString
|
// findSubString
|
||||||
// string set to lower
|
// string set to lower
|
||||||
// toLowerCase
|
// toLowerCase
|
||||||
// string get to delimiter
|
// string get to delimiter
|
||||||
// stringDelimiter
|
// stringDelimiter
|
||||||
// string get to end of line
|
// string get to end of line
|
||||||
// stringEOL
|
// stringEOL
|
||||||
|
|
||||||
// function implementations
|
// function implementations
|
||||||
|
|
||||||
|
|
@ -39,11 +39,11 @@ Dependencies: malloc, free, getStringLength
|
||||||
void catString(char *outString, const char *inString)
|
void catString(char *outString, const char *inString)
|
||||||
{
|
{
|
||||||
// initialize variables
|
// initialize variables
|
||||||
// set dest index
|
// set dest index
|
||||||
int destIndex = getStringLength(outString);
|
int destIndex = getStringLength(outString);
|
||||||
// set source str length
|
// set source str length
|
||||||
int sourceStrLen = getStringLength(inString);
|
int sourceStrLen = getStringLength(inString);
|
||||||
// create temp string pointer
|
// create temp string pointer
|
||||||
char *tempString;
|
char *tempString;
|
||||||
int sourceIndex = 0;
|
int sourceIndex = 0;
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ void catString(char *outString, const char *inString)
|
||||||
copyString(tempString, inString);
|
copyString(tempString, inString);
|
||||||
|
|
||||||
// loop to end of source string
|
// loop to end of source string
|
||||||
while(tempString[sourceIndex] != NULL_CHAR)
|
while (tempString[sourceIndex] != NULL_CHAR)
|
||||||
{
|
{
|
||||||
// assign characters to end of destination string
|
// assign characters to end of destination string
|
||||||
outString[destIndex] = inString[sourceIndex];
|
outString[destIndex] = inString[sourceIndex];
|
||||||
|
|
@ -93,12 +93,12 @@ int compareString(const char *firstString, const char *secondString)
|
||||||
int diff, index = 0;
|
int diff, index = 0;
|
||||||
|
|
||||||
// loop to end of string (within bounds)
|
// loop to end of string (within bounds)
|
||||||
while(firstString[index] != NULL_CHAR && secondString[index] != NULL_CHAR)
|
while (firstString[index] != NULL_CHAR && secondString[index] != NULL_CHAR)
|
||||||
{
|
{
|
||||||
// get diff of characters
|
// get diff of characters
|
||||||
diff = firstString[index] - secondString[index];
|
diff = firstString[index] - secondString[index];
|
||||||
// check diff of characters
|
// check diff of characters
|
||||||
if(diff != 0)
|
if (diff != 0)
|
||||||
{
|
{
|
||||||
// return diff
|
// return diff
|
||||||
return diff;
|
return diff;
|
||||||
|
|
@ -128,10 +128,10 @@ void copyString(char *outString, const char *inString)
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
// check to see if outString is not the same as inString.
|
// check to see if outString is not the same as inString.
|
||||||
if(outString != inString)
|
if (outString != inString)
|
||||||
{
|
{
|
||||||
// loop to end of inString
|
// loop to end of inString
|
||||||
while(inString[index] != NULL_CHAR)
|
while (inString[index] != NULL_CHAR)
|
||||||
{
|
{
|
||||||
// assign characters to end of outString
|
// assign characters to end of outString
|
||||||
outString[index] = inString[index];
|
outString[index] = inString[index];
|
||||||
|
|
@ -162,14 +162,14 @@ Dependencies: getStringLength
|
||||||
int findSubString(const char *testStr, const char *searchSubStr)
|
int findSubString(const char *testStr, const char *searchSubStr)
|
||||||
{
|
{
|
||||||
// initialize variables
|
// initialize variables
|
||||||
// initialize test string length
|
// initialize test string length
|
||||||
int testStrLength = getStringLength(testStr);
|
int testStrLength = getStringLength(testStr);
|
||||||
// initialize master index (location of substring start point)
|
// initialize master index (location of substring start point)
|
||||||
int masterIndex = 0;
|
int masterIndex = 0;
|
||||||
int searchIndex, internalIndex;
|
int searchIndex, internalIndex;
|
||||||
|
|
||||||
// loop across testStr
|
// loop across testStr
|
||||||
while(masterIndex < testStrLength)
|
while (masterIndex < testStrLength)
|
||||||
{
|
{
|
||||||
// set internal loop index to current test string index
|
// set internal loop index to current test string index
|
||||||
internalIndex = masterIndex;
|
internalIndex = masterIndex;
|
||||||
|
|
@ -177,14 +177,14 @@ int findSubString(const char *testStr, const char *searchSubStr)
|
||||||
searchIndex = 0;
|
searchIndex = 0;
|
||||||
// loop to end of testStr
|
// loop to end of testStr
|
||||||
// while testStr/searchSubStr characters are the same
|
// while testStr/searchSubStr characters are the same
|
||||||
while(internalIndex <= testStrLength &&
|
while (internalIndex <= testStrLength &&
|
||||||
testStr[internalIndex] == searchSubStr[searchIndex])
|
testStr[internalIndex] == searchSubStr[searchIndex])
|
||||||
{
|
{
|
||||||
// increment testStr and substring indices
|
// increment testStr and substring indices
|
||||||
internalIndex = internalIndex + 1;
|
internalIndex = internalIndex + 1;
|
||||||
searchIndex = searchIndex + 1;
|
searchIndex = searchIndex + 1;
|
||||||
// check for end of substring (search complete)
|
// check for end of substring (search complete)
|
||||||
if(searchSubStr[searchIndex] == NULL_CHAR)
|
if (searchSubStr[searchIndex] == NULL_CHAR)
|
||||||
{
|
{
|
||||||
// return beginning location of substring
|
// return beginning location of substring
|
||||||
return masterIndex;
|
return masterIndex;
|
||||||
|
|
@ -227,24 +227,23 @@ bool getStringConstrained(FILE *inStream, bool clearLeadingNonPrintable,
|
||||||
// capture first value in stream using fgetc
|
// capture first value in stream using fgetc
|
||||||
intChar = fgetc(inStream);
|
intChar = fgetc(inStream);
|
||||||
// loop to clear non-printable or space if indicated
|
// loop to clear non-printable or space if indicated
|
||||||
while((((intChar != EOF) &&
|
while ((intChar != EOF) &&
|
||||||
(clearLeadingNonPrintable && (intChar < (int)SPACE)))
|
((clearLeadingNonPrintable && intChar < (int)SPACE) || (clearLeadingSpace && intChar == (int)SPACE)))
|
||||||
|| (clearLeadingSpace && (intChar == (int)SPACE))))
|
|
||||||
{
|
{
|
||||||
// get next character in stream using fgetc
|
// get next character in stream using fgetc
|
||||||
intChar = fgetc(inStream);
|
intChar = fgetc(inStream);
|
||||||
}
|
}
|
||||||
// end loop to clear non-printable or space if indicated
|
// end loop to clear non-printable or space if indicated
|
||||||
// check for end of file found
|
// check for end of file found
|
||||||
if(intChar == EOF)
|
if (intChar == EOF)
|
||||||
{
|
{
|
||||||
// return false (failed)
|
// return false (failed)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// loop to get input from file stream
|
// loop to get input from file stream
|
||||||
while(((intChar != EOF && index < MAX_STR_LEN - 1) &&
|
while ((intChar != EOF && index < MAX_STR_LEN - 1) &&
|
||||||
(stopAtNonPrintable && intChar >= (int)SPACE))
|
((stopAtNonPrintable && intChar >= (int)SPACE) || (!stopAtNonPrintable)) &&
|
||||||
|| ((!stopAtNonPrintable) && (intChar != (char)delimiter)))
|
(intChar != (char)delimiter))
|
||||||
{
|
{
|
||||||
// [continues if not at end of file and max string len not reached ]
|
// [continues if not at end of file and max string len not reached ]
|
||||||
// [AND continues if not printable flag set and characters printable ]
|
// [AND continues if not printable flag set and characters printable ]
|
||||||
|
|
@ -342,26 +341,26 @@ Device output/---: NONE
|
||||||
Dependencies: getStringLength, malloc, copyString, free
|
Dependencies: getStringLength, malloc, copyString, free
|
||||||
*/
|
*/
|
||||||
void getSubString(char *destStr, const char *sourceStr,
|
void getSubString(char *destStr, const char *sourceStr,
|
||||||
int startIndex, int endIndex)
|
int startIndex, int endIndex)
|
||||||
{
|
{
|
||||||
// initialize variables
|
// initialize variables
|
||||||
// set length of source string using getStringLength
|
// set length of source string using getStringLength
|
||||||
int sourceStrLen = getStringLength(sourceStr);
|
int sourceStrLen = getStringLength(sourceStr);
|
||||||
// initialize the destination index to zero
|
// initialize the destination index to zero
|
||||||
int destIndex = 0;
|
int destIndex = 0;
|
||||||
// initialize source index to start index (parameter)
|
// initialize source index to start index (parameter)
|
||||||
int sourceIndex = startIndex;
|
int sourceIndex = startIndex;
|
||||||
// create pointer for temp string
|
// create pointer for temp string
|
||||||
char *tempStr;
|
char *tempStr;
|
||||||
|
|
||||||
// check for indices within limits
|
// check for indices within limits
|
||||||
if(startIndex >= 0 && startIndex <= endIndex && endIndex < sourceStrLen)
|
if (startIndex >= 0 && startIndex <= endIndex && endIndex < sourceStrLen)
|
||||||
{
|
{
|
||||||
// create temp string using malloc and copyString
|
// create temp string using malloc and copyString
|
||||||
tempStr = (char *)malloc(sourceStrLen + 1);
|
tempStr = (char *)malloc(sourceStrLen + 1);
|
||||||
copyString(tempStr, sourceStr);
|
copyString(tempStr, sourceStr);
|
||||||
// loop across requested substring indices
|
// loop across requested substring indices
|
||||||
while(sourceIndex <= endIndex)
|
while (sourceIndex <= endIndex)
|
||||||
{
|
{
|
||||||
// assign source character to destination element
|
// assign source character to destination element
|
||||||
destStr[destIndex] = tempStr[sourceIndex];
|
destStr[destIndex] = tempStr[sourceIndex];
|
||||||
|
|
@ -393,9 +392,9 @@ Dependencies: toLowerCase
|
||||||
void strToLowerCase(char *outString, const char *inString)
|
void strToLowerCase(char *outString, const char *inString)
|
||||||
{
|
{
|
||||||
// initialize variables
|
// initialize variables
|
||||||
// get source string length
|
// get source string length
|
||||||
int sourceStrLen = getStringLength(inString);
|
int sourceStrLen = getStringLength(inString);
|
||||||
// create temporary string pointer
|
// create temporary string pointer
|
||||||
char *tempStr;
|
char *tempStr;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
|
@ -403,7 +402,7 @@ void strToLowerCase(char *outString, const char *inString)
|
||||||
tempStr = (char *)malloc((sizeof(char) * (sourceStrLen + 1)));
|
tempStr = (char *)malloc((sizeof(char) * (sourceStrLen + 1)));
|
||||||
copyString(tempStr, inString);
|
copyString(tempStr, inString);
|
||||||
// loop across source string
|
// loop across source string
|
||||||
while(tempStr[index] != NULL_CHAR && index < MAX_STR_LEN)
|
while (tempStr[index] != NULL_CHAR && index < MAX_STR_LEN)
|
||||||
{
|
{
|
||||||
// set individual character to lowercase as needed, assigning back
|
// set individual character to lowercase as needed, assigning back
|
||||||
outString[index] = toLowerCase(tempStr[index]);
|
outString[index] = toLowerCase(tempStr[index]);
|
||||||
|
|
@ -433,7 +432,7 @@ Dependencies: none
|
||||||
char toLowerCase(char testChar)
|
char toLowerCase(char testChar)
|
||||||
{
|
{
|
||||||
// check for uppercase letter
|
// check for uppercase letter
|
||||||
if(testChar >= 'A' && testChar <= 'Z')
|
if (testChar >= 'A' && testChar <= 'Z')
|
||||||
{
|
{
|
||||||
// return lowercase letter
|
// return lowercase letter
|
||||||
return testChar - 'A' + 'a';
|
return testChar - 'A' + 'a';
|
||||||
|
|
|
||||||
|
|
@ -227,9 +227,9 @@ bool getStringConstrained(FILE *inStream, bool clearLeadingNonPrintable,
|
||||||
// capture first value in stream using fgetc
|
// capture first value in stream using fgetc
|
||||||
intChar = fgetc(inStream);
|
intChar = fgetc(inStream);
|
||||||
// loop to clear non-printable or space if indicated
|
// loop to clear non-printable or space if indicated
|
||||||
while((((intChar != EOF) &&
|
while((intChar != EOF) &&
|
||||||
(clearLeadingNonPrintable && (intChar < (int)SPACE)))
|
((clearLeadingNonPrintable && intChar < (int)SPACE)
|
||||||
|| (clearLeadingSpace && (intChar == (int)SPACE))))
|
|| (clearLeadingSpace && intChar == (int)SPACE)))
|
||||||
{
|
{
|
||||||
// get next character in stream using fgetc
|
// get next character in stream using fgetc
|
||||||
intChar = fgetc(inStream);
|
intChar = fgetc(inStream);
|
||||||
|
|
@ -242,9 +242,9 @@ bool getStringConstrained(FILE *inStream, bool clearLeadingNonPrintable,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// loop to get input from file stream
|
// loop to get input from file stream
|
||||||
while(((intChar != EOF && index < MAX_STR_LEN - 1) &&
|
while((intChar != EOF && index < MAX_STR_LEN - 1) &&
|
||||||
(stopAtNonPrintable && intChar >= (int)SPACE))
|
((stopAtNonPrintable && intChar >= (int)SPACE) || (!stopAtNonPrintable)) &&
|
||||||
|| ((!stopAtNonPrintable) && (intChar != (char)delimiter)))
|
(intChar != (char)delimiter))
|
||||||
{
|
{
|
||||||
// [continues if not at end of file and max string len not reached ]
|
// [continues if not at end of file and max string len not reached ]
|
||||||
// [AND continues if not printable flag set and characters printable ]
|
// [AND continues if not printable flag set and characters printable ]
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,15 @@ typedef enum {CPU_SCHED_SJF_N_CODE,
|
||||||
typedef struct ConfigDataTypeStruct
|
typedef struct ConfigDataTypeStruct
|
||||||
{
|
{
|
||||||
double version;
|
double version;
|
||||||
char metaDataFileName[STD_STR_LEN];
|
char metaDataFileName[MAX_STR_LEN];
|
||||||
int cpuSchedCode; // will need to be changed?
|
int cpuSchedCode;
|
||||||
int quantumCycles;
|
int quantumCycles;
|
||||||
bool memDisplay; // will need to be changed?
|
bool memDisplay;
|
||||||
int memAvailable;
|
int memAvailable;
|
||||||
int procCycleRate;
|
int procCycleRate;
|
||||||
int ioCycleRate;
|
int ioCycleRate;
|
||||||
int logToCode; // will need to be changed?
|
int logToCode;
|
||||||
char logToFileName[STD_STR_LEN]; // will need to be changed?
|
char logToFileName[MAX_STR_LEN];
|
||||||
} ConfigDataType;
|
} ConfigDataType;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ typedef struct OpCodeTypeStruct
|
||||||
char strArg1[MAX_STR_LEN];
|
char strArg1[MAX_STR_LEN];
|
||||||
int intArg2;
|
int intArg2;
|
||||||
int intArg3;
|
int intArg3;
|
||||||
int opEndTime;
|
double opEndTime;
|
||||||
struct OpCodeTypeStruct *nextNode;
|
struct OpCodeTypeStruct *nextNode;
|
||||||
} OpCodeType;
|
} OpCodeType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@ Dependencies: ???
|
||||||
*/
|
*/
|
||||||
void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
|
||||||
{
|
{
|
||||||
|
printf("runSim called here");
|
||||||
// void function, no return.
|
// void function, no return.
|
||||||
}
|
}
|
||||||
12
Sim01/testfile.cnf
Normal file
12
Sim01/testfile.cnf
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
Start Simulator Configuration File:
|
||||||
|
Version/Phase : 1.00
|
||||||
|
File Path : testfile.mdf
|
||||||
|
CPU Scheduling Code : FCFS-N
|
||||||
|
Quantum Time (cycles) : 55
|
||||||
|
Memory Available (KB) : 12000
|
||||||
|
Memory Display (On/Off) : On
|
||||||
|
Processor Cycle Time (msec) : 10
|
||||||
|
I/O Cycle Time (msec) : 20
|
||||||
|
Log To : Monitor
|
||||||
|
Log File Path : logfile_1.lgf
|
||||||
|
End Simulator Configuration File.
|
||||||
40
Sim01/testfile.mdf
Normal file
40
Sim01/testfile.mdf
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
Start Program Meta-Data Code:
|
||||||
|
sys start
|
||||||
|
app start, 0
|
||||||
|
dev in, hard drive, 18
|
||||||
|
cpu process, 9
|
||||||
|
cpu process, 9
|
||||||
|
cpu process, 9
|
||||||
|
dev out, monitor, 60
|
||||||
|
app end
|
||||||
|
app start, 0
|
||||||
|
dev in, sound signal, 40
|
||||||
|
dev in, hard drive, 30
|
||||||
|
dev in, sound signal, 25
|
||||||
|
cpu process, 6
|
||||||
|
dev out, usb, 10
|
||||||
|
app end
|
||||||
|
app start, 0
|
||||||
|
dev in, video signal, 70
|
||||||
|
cpu process, 10
|
||||||
|
dev out, monitor, 70
|
||||||
|
dev in, hard drive, 18
|
||||||
|
cpu process, 9
|
||||||
|
app end
|
||||||
|
app start, 0
|
||||||
|
dev in, sound signal, 35
|
||||||
|
dev out, monitor, 100
|
||||||
|
dev in, keyboard, 50
|
||||||
|
cpu process, 9
|
||||||
|
dev out, video signal, 49
|
||||||
|
app end
|
||||||
|
app start, 0
|
||||||
|
dev in, keyboard, 90
|
||||||
|
dev out, sound signal, 40
|
||||||
|
dev out, serial, 32
|
||||||
|
cpu process, 10
|
||||||
|
dev in, hard drive, 15
|
||||||
|
app end
|
||||||
|
sys end
|
||||||
|
End Program Meta-Data Code.
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue