0% found this document useful (1 vote)
6K views

Round Robin Scheduling Algorithm (With Different Arrival Time of Processes)

This document presents a C program that implements round robin scheduling with different arrival times for processes. It defines variables to store the burst time, arrival time, waiting time, turnaround time, and time quantum. It then inputs the burst times and arrival times for each process. Using a while loop and time quantum, it executes the processes based on their arrival times and calculates their waiting times and turnaround times. Finally, it prints the results.

Uploaded by

deepika_anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX or read online on Scribd
0% found this document useful (1 vote)
6K views

Round Robin Scheduling Algorithm (With Different Arrival Time of Processes)

This document presents a C program that implements round robin scheduling with different arrival times for processes. It defines variables to store the burst time, arrival time, waiting time, turnaround time, and time quantum. It then inputs the burst times and arrival times for each process. Using a while loop and time quantum, it executes the processes based on their arrival times and calculates their waiting times and turnaround times. Finally, it prints the results.

Uploaded by

deepika_anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX or read online on Scribd
You are on page 1/ 4

//round robin program with different arrival time of processes #include<stdio.h> #include<conio.

h> #define n 2 int main() { int bt[n],at[n],wt[n],tat[n]; int st[n]; int tq; int executed[n]; int timer=0; int temp=0; int i; int sq=0; printf("\nEnter the burst time in sequence\n "); for(i=0;i<n;i++) { scanf("%d",&bt[i]); } printf("\nEnter the arrival time in sequence(wrt 0 as starting time)\n "); for(i=0;i<n;i++) { scanf("%d",&at[i]); } for(i=0;i<n;i++)

st[i]=bt[i]; for(i=0;i<n;i++) { wt[i]=0; tat[i]=0; executed[i]=0; } printf("\n Enter the time quantum - "); scanf("%d",&tq); int count=0; //i=0; while(1) { for(i=0;count<n;timer++) { if(at[i]<=timer)//if process ahs arrived before the timer { temp=tq; if(st[i]==0) { i=(i+1)%n; count++; continue;

if(st[i]>tq) { st[i]-=tq; //executed[i]=tq; } else if(st[i]>0) { //executed[i]=st[i]; temp=st[i]; st[i]=0; } sq+=temp;

tat[i]=sq; i=(i+1)%n; }//only if at[i]<timer else//otherwise just continue with the next program { i=(i+1)%n; continue; } }//end of for loop // timer++; if(n==count)

break; }//end of while //calculation for(i=0;i<n;i++) { wt[i]=tat[i]-bt[i]-at[i] ; } printf("\nPROCESSNO BURSTTIME ARRIVALTIME WAITTIME Turnaround time\n"); for(i=0;i<n;i++) printf("p%d\t%d\t%d\t\t%d\t\t%d\n",i+1,bt[i],at[i],wt[i],tat[i]); //printf("\n%d",swt/MAX); getch(); return 0; }

DEEPIKA ANAND NSIT IT

You might also like