Skip to main content

Posts

implement the Round robin scheduling algorithm(Assignment-7)

Write a program to implement the Round robin scheduling algorithm. Use the example given in the manual as your test case. Code: #include<stdio.h> int main() { int count,j,n,time,remain,flag=0,time_quantum; int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10]; printf("Enter Total Process:\t "); scanf("%d",&n); remain=n; for(count=0;count<n;count++) { printf("Enter Arrival Time and Burst Time for Process Process Number %d :",count+1); scanf("%d",&at[count]); scanf("%d",&bt[count]); rt[count]=bt[count]; } printf("Enter Time Quantum:\t"); scanf("%d",&time_quantum); printf("\n\nProcess\t|Turnaround Time|Waiting Time\n\n"); for(time=0,count=0;remain!=0;) { if(rt[count]<=time_quantum && rt[count]>0) { time+=rt[count]; rt[count]=0; flag=1; } else if(rt[count]>0) { rt[count]-=time_quantum; time+

implement the Priority Scheduling scheduling algorithm(assignment-7)

ASSIGNMENT-7 1) 1. Write a program to implement the Priority Scheduling scheduling algorithm. Use the example given in the manual as your test case. Code: #include<stdio.h> int main() { int bt[20],p[20],wt[20],tat[20],pr[20],i,j,n,total=0,pos,temp,avg_wt,avg_tat; printf("Enter Total Number of Process:"); scanf("%d",&n); printf("\nEnter Burst Time and Priority\n"); for(i=0;i<n;i++) { printf("\nP[%d]\n",i+1); printf("Burst Time:"); scanf("%d",&bt[i]); printf("Priority:"); scanf("%d",&pr[i]); p[i]=i+1; //contains process number } //sorting burst time, priority and process number in ascending order using selection sort for(i=0;i<n;i++) { pos=i; for(j=i+1;j<n;j++) { if(pr[j]<pr[pos]) pos=j; } temp=pr[i]; pr[i]=pr[pos]; pr[pos]=temp; temp=bt[i]; bt[i]=bt[pos]; bt[pos]=temp; temp=p[i]; p[i]=p