I would like to know if any one know what are the steps of setting up code for CPU Scheduling. I must develop a simulation program for CPU scheduling.

-First I have to use FCFS(first come first serve) algorithm that will read the first number that me or anybody put into the data file.

-Then my program will tell you the times in which each program takes to finish and the average waiting time; which is the total time divided by the amount of process that will be give but will be different by each user.
The same with goes for SJF the only different with SJFS is the shorts time program goes first.

-The next algorithm my program will implement is Priority, and priority is the most important program to the particular user will go first and finish then next in order of importance.

-Next will be Round Robin (RR) with a time quantum that will be in the data file. The time quantum decides how the RR will run because it tell how much time it will spend on each process
All algorithms will give an average waiting time (AWT) for now my program will be in C++

My teacher is difficult because he wants us to be better programmers but some computer science majors are not really concentrating on that field so programming is not my expertise but I have done basic program, when it gets to these difficults one I loose my mind. I know how to set up a data file and set up maybe the beginning with the #<iostreams> after that I know to list variables and I am Lost

I had to do this as well for my Operating Systems class. It wasn't the best code I have ever written. Well I usually work with the nuts and bolts first when I write code, so that is probably the best way to explain my chain of thought.

First I wrote a process class that held all the information about an individual process that I would need. The main pieces of information I was concerned with was the arrival time (don't know if this is somethign you need to take into consideration or not), time spent in the ready queue, time spent in the cpu, and the time left on the process. The class consisted of a lot of retrieve variable functions and a few modifier functions to set these variables. I also wrote a function in the class that would be used if the process in the cpu was preempted. This function would basically create a new process with the same information but would maintain a variable saying that it was preempted at such and such a time.

I had to write algorithms for SJF, Preemptive SJF (I really really hated this one, so be thankful your professor is only making you do the easy version), RR and FCFS. They were all pains in the ass. I used the list class from the stl to store my process class. I first initialized a list of processes as my test case. I basically used the same algorithm for all, but I had to make alterations to each simulation to accomadate. Just keep track of how much burst time is left on each one. For SJF use the first process as your first job, then search through the list to find the next shortest job and insert it after the job you just completed. You will understand the importance of keeping them in order later. For RR you will need to take preemption into consideration and this is where the function that returns a process in my process class is important. The process that it returns should be pushed onto the back of the list of processes.

Assuming that you were able to write the algorithms and they worked, you now have a list that has a ton of information in it. From this list you can figure out the overhead from the number of context switches in the cpu, the total burst time for the process set, the throughput, and the average wait and turnaround time. I will let you figure that out on your own.

There was one big thing that I wish I was able to do with this program and that was to output gannt charts to the results file. These lists are formatted so that it would be easy. I was strapped for time, and could not implement this feature.

Anyway good luck with this project. Spend an hour a day working on it long before it is due and you should be fine (I was a moron and started it 2 days before it was due).

Hi guys,
I am running into the same situation, can I please have some of your code so I can look at it? I really need to get started with this as It is due very soon.
There's some similarity with what I was asked to do for my operating system class.
I am web developer and would gladly help you in anything to do with web stuff.
I appreciate your help.
Thank you in advance.


How about trying it for yourself rather than hijacking a thread which is over 2 YEARS old.

You're not going to learn to cook from reading cookery books, and I can tell you that all great cooks didn't get where they are today without setting fire to something at least once.

i am Charmaine 18 years old taking Bachelor of Science in Information and technology here in La Salle Bacolod Philippines will you please teach me abOut CPU Scheduling algorthim Simulation....Thank you soo mUch....

WHat is to be mentioned in the input file??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.