LTScheduler: //Long Term Scheduler Object Data Members: Private NewQueue of PCB //The New-Process Queue Member Functions: Public constructor(); //Create a PCB for each process and queue them up in //order of creation time. destructor(); //Destruct everything PCB *CheckNewP(time); //Check for newly created processes. If any are found, //return a pointer to it (the PCB) -------------------------------------------------------------------------- STScheduler: //Short Term Scheduler Object Data Members: Private ReadyQ of PCBQ //The ready queue WaitingQ of PCBQ //The waiting queue TermQueue of PCBQ //The Terminated Process Queue ??Current of *PCB //PID of the current process NumPending of int //number of pending processes Member Functions: Public constructor(string f1, string f2, string f3); //Open each 'tape' file using filename arguements. Build //a process control block for each and set some initial //values. destructor(); //destruct the STScheduler object Manage(TYPE of scheduling, time); //Given the "TYPE of scheduling" algorithm desired, call //a simulation method to decide which process should get //this timeslice. Update the simulation statistics for //that process / or all processes???. Member Functions: Private FCFS(time); //First Come First Serve Scheduling Algorithm: //Given the current clock value compare this against //the total running time to see if the process has //completed. If so, mark it as being on the TermQ queue //and get the next process from the ready queue. That //is, search the ReadyQ for the process with the //earliest creation time. RR(time); //Round Robin Scheduling Algorithm: //Given the current clock value check to see if current //process has completed. If so, put it on the TermQ //and get the next process from the ReadyQ. If it has //not completed, check to see if the timeslice has expired. //If it has, check to see if it is in a section of code //that can be preempted. If it is ok to preempt, put it //on the WaitingQ and get the next process. Otherwise, let //it stay on the CPU but do NOT reset the timeslice counter Priority(time); //Priority based Scheduling Algorithm: //Check the ReadyQ for the process with the highest //priority. If the current process is currently in a //CC (OR IO?) section, enact priority inversion. Else, //put the higher priority process on the CPU. int GetNumPending(); //return the number of pending processes. -------------------------------------------------------------------------- PCB: //Process Control Block object enum Qstate = {ReadyQ, WaitingQ, TermQ, Running} Data Members: //General Process Information int PID; //Process ID number int CreateTime; //Clock Time the process was created int Priority; //Process Priority EventQ Pevents; //Q of future process events //Current Process State Information ?? Qstate CurrentQ; //Which Queue the process is in Events CurEvent; //The current Process Event int ETimeRem; //Remaining Time for current Event //Simulation Statistics int Waittime; //Total Time spent in the WaitingQ int TurnTime; //Total Turnaround Time Member Functions: Public consatructor(); destructor(); //Get Member Functions int getPriority(); //return the process priority Events getCurEvent(); //return the current event Etc....... ??? Age(???); //Time passes. The process statistics are updated to //reflect the passage of another clock tick. -------------------------------------------------------------------------- EventQ: //Queue of process events and duration enum Events = {CC, CR, IO, SL} Data Members: Private struct EventBlock *NodePtr; struct EventBlock { Events event; //The Event Code int duration; //The Event Duration NodePtr next; //The Next EventBlock } NodePtr Current; Member Functions: Public constructor(); destructor(); Etc....Standard Queue Functions This module will be stolen from the 15b directory (Kent Woldridge) -------------------------------------------------------------------------- PCBQ: //Queue of process events and duration Data Members: Private struct PCB *NodePtr; struct PCB { PCB *PCBP; //The Event Duration NodePtr next; //The Next PCB node } NodePtr Current; Member Functions: Public constructor(); destructor(); Etc....Standard Queue Functions This module will be stolen from the 15b directory (Kent Woldridge) -------------------------------------------------------------------------- Clock: //Clock Counter Object Data Members: Private CurTime of int //Current clock value Member Functions: Public constructor(); destructor(); int Incriment(); //Incriment CurTime by 1 and pass back the new value int GetCurTime(); //Return the current time int Jump(int distance) //Add distance to CurTime, where distance is a positive //OR negetive value. This allows both forward and backward //time travel of arbitrary magnitide. Reset(); //reset CurTime to 0; -------------------------------------------------------------------------- Main: for(type = 1 to 3) { do{ time = clock.Incriment(); //This is a new time LTS.CheckNew(time); //Check for newly created processes STS.Manage(type, time); //Do Scheduling while(any process is still active); Generate_Report_for_each_Process; }