Operating-System-Simulator / Sim02 / datatypes.h
datatypes.h
Raw
#ifndef DATATYPES_H
#define DATATYPES_H

#include <stdio.h>
#include <stdbool.h>
#include "pthread.h"

typedef struct ConfigDataType
{
 double version;
 char *metaDataFileName[ 100 ];
 int cpuSchedCode;
 int quantumCycles;
 int memAvailable;
 int procCycleRate;
 int ioCycleRate;
 int logToCode;
 char *logToFileName[ 100 ];
}ConfigDataType;

// Linked list to write to file at the end of the program
typedef struct fileWriteList
{
 char *strToWrite;
 struct fileWriteList *nextStr;
}fileWriteList;

typedef struct OpCodeType
{
 int pid;               // pid, added when PCB is created
 char command[ 5 ];     // three letter command quantity
 char inOutArg[ 5 ];    // for device in/out
 char strArg1[ 15 ];    // arg 1 descriptor, up to 12 chars
 int intArg2;           // cycles or memory, assumes 4 byte int
 int intArg3;           // memory, assumes 4 byte int
                        // also non/preemption indicator
 double opEndTime;      // size of time string returned from accessTimer
 struct OpCodeType *nextNode; // pointer to next node as needed
}OpCodeType;

typedef struct PCB
{
 int pid;                    // process id
 int state;
 OpCodeType *programCounter; // PC to next op code
 void *timeThreadPtr;        // pointer to keep track of timing thread
 int timeRemaining;          // time in ms remaining on process
 bool interruptable;         // if the process is in the middle of a sensitive operation
}PCB;

typedef struct PCBLinkedList
{
 PCB* PCB;
 struct PCBLinkedList* nextPCB;
}PCBLinkedList;

typedef struct threadInfo  // struct passed into timer thread to manage operations
{
 long milliseconds;         // time limit on thread (int was overflowing in timer)
 int currentTime;
 char *timeString;
 bool outputTime;          // request that thread updates the timeString 
 bool keepGoing;
 pthread_mutex_t mutex;
}threadInfo;

#endif // DATATYPES.h