CPU Scheduling Program in C++ - Code With C
CPU Scheduling Program in C++ - Code With C
In the beginning of the program, I define a class name ‘cpuschedule’, the class contains seven public methods.
Getdata method contains the user input for no. of process and burst time for process. Fcfs method calculates First come First
served Algorithm and show the Total and Average Weighting Time. Sjf method calculates Shortest job First Algorithm, SjfNp is
Shortest job First Algorithm with Non Preemptive, SjfP is Shortest job First Algorithm with Preemption and RoundRobin method is
Round Robin Algorithm and show the Total and Average Weighting Time.
The main function, in the main function there is a infinity loop with a termination point. When the user enters an choice the with
the following number the program goes to the corresponding method call the Algorithm or User Input for calculation.
Method definition:
Fcfs():
Step 3: after that, the third loop in the method calculates the total weight time and we can divide the total time with the no. of
process to find the average time.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the
use of ALL the cookies.
Step 1: firstly the program loops through the time for process then
Step 3: calculate the weight by adding the previous value of weight and the burst time which stored inside the array.
Step 4: finally the total weighting time is calculate by adding the current time and weight
SjfNp():
Step 1: in the beginning of the method it prints out the burst time for the process and gets the input from the arrival time of the
process.
Step 2: after that the burst array and arrival time array sort their position by ascending order.
Step 3: now program prints the burst time and arrival time.
Step 4: the total weighting time is calculate by adding the current time with the result of weight subtracting by the arrival time.
Step 5: finally the average weight calculation, total weight divide by the number of processes.
Priority()
Step 1: shows Burst time and get input from the priority for process from the user
Step 3: then the method loop through the current time and adding the time with all weights in the array to find the total time and
divide by the processes will show the average time.
SjfP():
Step 1: in the beginning of the method it prints out the burst time for the process and gets the input from the arrival time of the
process and we calculate assign the biggest value of arrival time in the time variable.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the
Step 2: now while the t is less than Time and if arrival time is less or equal t and burst time not equals zero then the program
use of ALL the cookies.
Step 4: after that the weight info shows in the console by loop
Step 5: now after subtracting the arrival time with the weight the program calculate the total time and average time.
RoundRobin():
Step 1: in the beginning of the method it prints out the burst time.
Step 7: calculate the weighting time, total time and average time.
Password:codewithc.com
[/sociallocker]
CODEWITHC
© CODEWITHC.COM. All rights reserved.
Code with C is a comprehensive compilation of Free projects, source codes, books, and tutorials in Java, PHP,.NET, Python, C++, in C programming language, and more. Our
We use cookies onmain mission
our websiteis to help out programmers
to give and relevant
you the most coders, students and learners
experience in general, with relevant
by remembering resources and materials
your preferences and repeatin thevisits.
field of computer programming.
By clicking “Accept”, you consent to the
use of ALL the cookies.
C++ PROJECTS
PYTHON PROJECTS
ASP.NET PROJECTS
PHP PROJECTS
About Us
HOME
ABOUT US
CONTACT US
TERMS OF USE
PRIVACY POLICY
Popular Category
C TUTORIALS 155
BLOG 86
C++ TUTORIAL 72
JAVA TUTORIALS 53
C PROJECTS 51
ASP.NET PROJECTS 48
JAVA PROJECTS 44
PYTHON TUTORIALS 39
Editor Picks
C Programming Language – A Step By Step Beginners Guide – 2023
December 14, 2022
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the
use of ALL the cookies.