EXPERIMENT
OBJECTIVE
*Write a C program to simulate multi-level
queue scheduling algorithm considering the following scenario. All
the processes in the system are divided into two categories – system
processes and user processes. System
processes are to be given higher priority than user processes. The
priority of each process ranges from 1 to 3.
Use fixed priority scheduling for all the processes.
DESCRIPTION
Multi-level queue scheduling algorithm is used in scenarios where the
processes can be classified into groups
based on property like process type, CPU time, IO access, memory size,
etc. In a multi-level queue scheduling
algorithm, there will be 'n' number of queues, where 'n' is the number
of groups the processes are classified
into. Each queue will be assigned a priority and will have its own
scheduling algorithm like round-robin
scheduling or FCFS. For the process in a queue to execute, all the
queues of priority higher than it should be
empty, meaning the process in those high priority queues should have
completed its execution. In this
scheduling
algorithm, once assigned to a queue, the process will not move to any other
queues.
coding
main()
{
int
p[20],bt[20], su[20], wt[20],tat[20],i, k, n, temp;
float
wtavg, tatavg;
clrscr();
printf("Enter
the number of processes --- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
p[i] = i;
printf("Enter
the Burst Time of Process %d --- ", i);
scanf("%d",&bt[i]);
printf("System/User
Process (0/1) ? --- ");
scanf("%d",
&su[i]);
}
for(i=0;i<n;i++)
for(k=i+1;k<n;k++)
if(su[i]
> su[k])
{
temp=p[i];
p[i]=p[k];
p[k]=temp;
temp=bt[i];
bt[i]=bt[k];
bt[k]=temp;
temp=su[i];
su[i]=su[k];
su[k]=temp;
}
wtavg =
wt[0] = 0;
tatavg =
tat[0] = bt[0];
for(i=1;i<n;i++)
{
wt[i] =
wt[i-1] + bt[i-1];
tat[i] =
tat[i-1] + bt[i];
wtavg =
wtavg + wt[i];
tatavg =
tatavg + tat[i];
}
printf("\nPROCESS\t\t
SYSTEM/USER PROCESS \tBURST TIME\tWAITING TIME\tTURNAROUND TIME");
for(i=0;i<n;i++)
printf("\n%d
\t\t %d \t\t %d \t\t %d \t\t %d ",p[i],su[i],bt[i],wt[i],tat[i]);
printf("\nAverage
Waiting Time is --- %f",wtavg/n);
printf("\nAverage
Turnaround Time is --- %f",tatavg/n);
getch();
}
thank you....
ReplyDeletebt there are a few loopholes in the code though.
Which type of scheduling is used for user process in the above example? Is this largest job first type scheduling?
ReplyDeleteJSON Parsing with Example
ReplyDeleteGeneral Model for Sequential or State Machine
Generic Model: Digital Signature
Good leader Qualities
Color and Greyscale Levels
Hamiltonian Problem
Hash Functions: Cipher Block Chaining
Hashing Functions with Example
Heap Sort Algorithm
Height Balanced Tree
Hermit Interpolation
ReplyDeleteHeuristics for Planning using Constraint Posting
Hexadecimal counter program
Computer Network
Operating System
Code Optimization Technique
Error Detection and Correction Techniques
Evaluation Expression Process
Evolution Frames
its working perfectly...Really Helpful
ReplyDeletegreat. can i get the codes in c++ or java?
ReplyDelete