0% found this document useful (0 votes)
17 views3 pages

Round Robin Scheduling

The document is a C program that implements the Round Robin scheduling algorithm for process management. It takes user input for the number of processes and their burst times, as well as the time slice, and calculates the average turnaround and waiting times for each process. The program outputs the completion time for each process along with a summary of burst time, waiting time, and turnaround time.

Uploaded by

boyzkiller9876
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Round Robin Scheduling

The document is a C program that implements the Round Robin scheduling algorithm for process management. It takes user input for the number of processes and their burst times, as well as the time slice, and calculates the average turnaround and waiting times for each process. The program outputs the completion time for each process along with a summary of burst time, waiting time, and turnaround time.

Uploaded by

boyzkiller9876
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

h>

int main() {

int i, j, n, bu[10], wa[10], tat[10], t, ct[10], max;

float awt = 0, att = 0, temp = 0;

// Input the number of processes

printf("Enter the number of processes -- ");

scanf("%d", &n);

// Input the burst time for each process

for(i = 0; i < n; i++) {

printf("\nEnter Burst Time for process %d -- ", i + 1);

scanf("%d", &bu[i]);

ct[i] = bu[i]; // Copy burst time to ct for future use

// Input the time slice

printf("\nEnter the size of time slice -- ");

scanf("%d", &t);

// Determine the maximum burst time

max = bu[0];

for(i = 1; i < n; i++) {

if(max < bu[i]) {

max = bu[i];

// Process the tasks using Round Robin scheduling

for(j = 0; j < (max / t) + 1; j++) {


for(i = 0; i < n; i++) {

if(bu[i] != 0) {

if(bu[i] <= t) {

// Process completes in this cycle

tat[i] = temp + bu[i];

temp += bu[i];

bu[i] = 0;

printf("Process %d completed at time %f\n", i + 1, temp);

} else {

// Process doesn't complete, reduce its burst time by the time slice

bu[i] -= t;

temp += t;

// Calculate waiting time and average turnaround/waiting times

for(i = 0; i < n; i++) {

wa[i] = tat[i] - ct[i];

att += tat[i];

awt += wa[i];

// Display the average turnaround and waiting time

printf("\nThe Average Turnaround time is -- %f", att / (float)n);

printf("\nThe Average Waiting time is -- %f", awt / (float)n);

// Display the burst time, waiting time, and turnaround time for each process

printf("\n\tPROCESS\t BURST TIME \t WAITING TIME\tTURNAROUND TIME\n");

for(i = 0; i < n; i++) {


printf("\t%d \t %d \t\t %d \t\t %d \n", i + 1, ct[i], wa[i], tat[i]);

return 0;

Enter the number of processes -- 3

Enter Burst Time for process 1 -- 10

Enter Burst Time for process 2 -- 8

Enter Burst Time for process 3 -- 7

Enter the size of time slice -- 5

Process 1 completed at time 20.000000

Process 2 completed at time 23.000000

Process 3 completed at time 25.000000

The Average Turnaround time is -- 22.666666

The Average Waiting time is -- 14.333333

PROCESS BURST TIME WAITING TIME TURNAROUND TIME

1 10 10 20

2 8 15 23

3 7 18 25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy