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

Programming in C - CPU Scheduling - Round Robin

Kamalesh Kumar Singh wrote a blog post about implementing Round Robin CPU scheduling in C. The post describes the theory behind Round Robin scheduling, where each job is given a time quantum or slot and preempted if not completed within that time. An example is given where a job taking 250ms would be suspended after 100ms and resumed once other jobs had their turns. The C program implementation includes functions to input process details, calculate waiting times and turnaround times, and output the results. It uses a time quantum, decrements remaining time by the quantum amount each round, and ends when all processes have been executed.

Uploaded by

Genus Sum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
176 views3 pages

Programming in C - CPU Scheduling - Round Robin

Kamalesh Kumar Singh wrote a blog post about implementing Round Robin CPU scheduling in C. The post describes the theory behind Round Robin scheduling, where each job is given a time quantum or slot and preempted if not completed within that time. An example is given where a job taking 250ms would be suspended after 100ms and resumed once other jobs had their turns. The C program implementation includes functions to input process details, calculate waiting times and turnaround times, and output the results. It uses a time quantum, decrements remaining time by the quantum amount each round, and ends when all processes have been executed.

Uploaded by

Genus Sum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

2/15/2014

Programming in c: CPU scheduling : Round Robin

Programming in c
ABOUT ME

Kamalesh Kumar Singh


View my complete profile

SUNDAY, FEBRUARY 6, 2011

CPU scheduling : Round Robin

OBJECTIVE: Write a program in c to implement Round Robin scheduling.


THEORY: Round-robin job scheduling may not be desirable if the sizes of the jobs or tasks are highly variable. A process

that produces large jobs would be favoured over other processes. This problem may be solved by time-sharing, i.e. by giving
each job a time slot or quantum (its allowance of CPU time), and interrupt the job if it is not completed by then. The job is
resumed next time a time slot is assigned to that process.
Example: The time slot could be 100 milliseconds. If job1 takes a total time of 250ms to complete, the round-robin
scheduler will suspend the job after 100ms and give other jobs their time on the CPU. Once the other jobs have had their
equal share (100ms each), job1 will get another allocation of CPU time and the cycle will repeat. This process continues
until the job finishes and needs no more time on the CPU.

PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
int st[10],bt[10],wt[10],tat[10],n,tq;

POPULAR POSTS

int i,count=0,swt=0,stat=0,temp,sq=0;
float awt=0.0,atat=0.0;

CPU scheduling : Round


Robin
OBJECTIVE: Write a
program in c to implement
Round Robin scheduling.
THEORY: Round-robin
job scheduling may not be
desirable if the sizes ...

clrscr();

Fractional Knapsack
Problem
OBJECTIVE:
Implementation of
fractional knapsack
problem. THEORY: The
Fractional Knapsack
Problem usually sounds
like this: Thief has ju...

st[i]=bt[i];

Critical section Problem


Using Dekker's Algorithm
OBJECTIVE: Write a
program for synchronizing
of critical section problem
using Dekkers Algorithm.
THEORY: In concurrent
programming a cri...

temp=tq;

printf("Enter number of processes:");


scanf("%d",&n);
printf("Enter burst time for sequences:");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
printf("Enter time quantum:");
scanf("%d",&tq);
while(1)
{
for(i=0,count=0;i<n;i++)
{
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)

http://iitkamalesh.blogspot.com/2011/02/cpu-scheduling-round-robin.html

1/3

2/15/2014

Programming in c: CPU scheduling : Round Robin

Banker's Algorithm
OBJECTIVE:
Implementation of
Banker's Algorithm.
THEORY: The Banker's
algorithm is run by the
operating system
whenever a proces...
Process Synchronization
idealstudent.blogger.com
Synchronizing POSTFIX
thread using MUREX
variable
OBJECTIVE: Write a
Program for synchronizing
POSTFIX thread using
Murex variable. THEORY:
Technically, a thread is
defined as an
independen...

st[i]=st[i]-tq;
else
if(st[i]>=0)
{
temp=st[i];
st[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
if(n==count)
break;
}
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}

Program to restrict
keyboard using c++
#include #include
#include using
namespace std; int main()
{ char input[250] = {'\0'};
char *i = input; char c; ...

awt=(float)swt/n;

Dinning Philosopher
Problem
OBJECTIVE :
Implementation of process
synchronization(DINNING
PHILOSOPHER
PROBLEM) THEORY:
The goal of problem is to
create a program that ...

",i+1,bt[i],wt[i],tat[i]);

Heap Sort
OBJECTIVE:
Implementation of heap
sort. THEORY: Heapsort
primarily competes with
quicksort, another very
efficient general purpose
nearly-...
N Queen Problem
OBJECTIVE: c
Implementation of NQueen problem.
THEORY: The concept of
N queens problem is that
we need to place N
queens in N x N matrix ...

atat=(float)stat/n;
printf("Process_no Burst time Wait time Turn around time
");
for(i=0;i<n;i++)
printf("%d %d %d %d
printf("Avg wait time is %f
Avg turn around time is %f",awt,atat);
getch();
}

Posted by Kamalesh Kumar Singh at 12:14 AM

No comments:
Post a Comment

Enter your comment...

Comment as:

Publish

Google Account

Preview

TOTAL PAGEVIEWS

12,560
BLOG ARCHIVE

2011 (15)
March (1)
February (14)
Program to restrict
keyboard using
c++
How can I make my
blog load faster? -

http://iitkamalesh.blogspot.com/2011/02/cpu-scheduling-round-robin.html

2/3

2/15/2014

Programming in c: CPU scheduling : Round Robin


Blogger Help...
Process
Synchronization
Dinning Philosopher
Problem
Critical section
Problem Using
Dekker's
Algorithm
Synchronizing
POSTFIX thread
using MUREX
variable
Banker's Algorithm
CPU scheduling :
Round Robin

Newer Post

Home

0/1 Knapsack
Problem

Subscribe to: Post Comments (Atom)

Older Post

kruskal Algorithms
Fractional Knapsack
Problem
N Queen Problem
Heap Sort
Self

FOLLOWERS
Join this site
w ith Google Friend Connect

Members (3)

Already a member? Sign in

Picture Window template. Powered by Blogger.

http://iitkamalesh.blogspot.com/2011/02/cpu-scheduling-round-robin.html

3/3

You might also like