Modified timer function and such to stop the warnings.

This commit is contained in:
Charles Descamps 2024-04-08 13:19:52 -07:00
parent 5d8edb8271
commit 022ca3ac06
5 changed files with 55 additions and 13 deletions

View file

@ -599,12 +599,13 @@ void runCPU(char *command, char *argument, int intArg, ConfigDataType *configPtr
// int intArg = workingMeta->intArg2;
char cpuOutput[MAX_STR_LEN];
int cpuTime = 0;
int *cpuTimePtr = &cpuTime;
cpuTime = intArg * configPtr->procCycleRate;
sprintf(cpuOutput, "%f, Process: %d, %s %s operation start\n", accessTimer(LAP_TIMER, timeStringy), processId, command, argument);
logOutput(configPtr, cpuOutput, false);
// run timer for intArg * procCycleRate
pthread_t cpuThread;
pthread_create(&cpuThread, NULL, (void *)&simThread, (void *)cpuTime);
pthread_create(&cpuThread, NULL, runTimer, (void *)cpuTimePtr);
pthread_join(cpuThread, NULL);
sprintf(cpuOutput, "%f, Process: %d, %s %s operation end\n", accessTimer(LAP_TIMER, timeStringy), processId, command, argument);
logOutput(configPtr, cpuOutput, false);
@ -626,11 +627,12 @@ void runIO(char *command, char *argument, int intArg, ConfigDataType *configPtr,
char timeStringy[MAX_STR_LEN];
char ioOutput[MAX_STR_LEN];
int ioTime = 0;
int *ioTimePtr = &ioTime;
ioTime = intArg * configPtr->ioCycleRate;
sprintf(ioOutput, "%f, Process: %d, %s %s operation start\n", accessTimer(LAP_TIMER, timeStringy), processId, command, argument);
logOutput(configPtr, ioOutput, false);
pthread_t ioThread;
pthread_create(&ioThread, NULL, (void *)&simThread, (void *)ioTime);
pthread_create(&ioThread, NULL, runTimer, (void *)ioTimePtr);
pthread_join(ioThread, NULL);
sprintf(ioOutput, "%f, Process: %d, %s %s operation end\n", accessTimer(LAP_TIMER, timeStringy), processId, command, argument);
logOutput(configPtr, ioOutput, false);
@ -782,13 +784,15 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
processCount = processCount + 1;
}
pcbPtr = pcbList->headPtr;
int *totalPCBTimePtr = &totalPCBTime;
pthread_t cpuThread;
pthread_create(&cpuThread, NULL, (void *)&simThread, (void *)totalPCBTime);
pthread_create(&cpuThread, NULL, runTimer, (void *)totalPCBTimePtr);
//
int processTimeLeft = pcbPtr->timeLeft;
int *processTimeLeftPtr = &processTimeLeft;
// set the current process id to the first scheduled process
currentPid = scheduleProcess(pcbList, configPtr);
@ -811,7 +815,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
sprintf(simulatorOutput, "%f, OS: Process %d set to RUNNING state from READY state\n\n", accessTimer(LAP_TIMER, timeStringy), pcbPtr->uniquePid);
logOutput(configPtr, simulatorOutput, false);
pthread_t runThread;
pthread_create(&runThread, NULL, (void *)&simThread, (void *)processTimeLeft);
pthread_create(&runThread, NULL, runTimer, (void *)processTimeLeftPtr);
runProcess(pcbPtr, configPtr, pcbList);
// when finished, set to terminated
sprintf(simulatorOutput, "%f, OS: Process %d set to TERMINATED state from RUNNING state\n\n", accessTimer(LAP_TIMER, timeStringy), pcbPtr->uniquePid);
@ -820,6 +824,7 @@ void runSim(ConfigDataType *configPtr, OpCodeType *metaDataMstrPtr)
pthread_join(runThread, NULL);
}
processTimeLeft = pcbPtr->timeLeft;
processTimeLeftPtr = &processTimeLeft;
pcbPtr = pcbPtr->nextPtr;
}
currentPid = scheduleProcess(pcbList, configPtr);
@ -1007,8 +1012,8 @@ Device Input/Device: none
Device Output/Device: none
Dependencies: pthreads, runTimer
*/
void *simThread(int milSec)
{
runTimer(milSec);
pthread_exit(NULL);
}
// void *simThread(int milSec)
// {
// runTimer(milSec);
// pthread_exit(NULL);
// }