Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Disk Scheduling System Simulation: FIFO Strategy Analysis - Prof. Saumendra Sengupta, Study notes of Operating Systems

A c++ program simulating the first-in-first-out (fifo) disk scheduling strategy. The program generates random requests and calculates the average and variance of head movements. The output shows that the results are uniformly distributed as expected.

Typology: Study notes

Pre 2010

Uploaded on 08/09/2009

koofers-user-8r7-1
koofers-user-8r7-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A simple disk-scheduling system.
#include <iostream.h>
#include <math.h>
#include <time.h>
int rand(int&);
void clear(double [], int);
const int multip = 7919; // a prime number;
const int modulr = 7879; // a prime number;
main()
{
int fin = 100;
int i,j;
int n=10000;
int req[10000];
double moves[10000];
int seed = time(NULL)%1000;
for (int run=0; run <50; run++)
{
int start=0;
double movesum = 0.0;
double average = 0.0;
double variance = 0.0;
double vsum = 0.0;
clear(req,n);
clear(moves,n);
for (i=0; i<n; i++) // Generate n requests in req array
{
req[i]=rand(seed);
j=abs(req[i]-start);
moves[i]=double(j)/100.0;
pf3

Partial preview of the text

Download Disk Scheduling System Simulation: FIFO Strategy Analysis - Prof. Saumendra Sengupta and more Study notes Operating Systems in PDF only on Docsity!

A simple disk-scheduling system. #include <iostream.h> #include <math.h> #include <time.h> int rand(int&); void clear(double [], int); const int multip = 7919; // a prime number; const int modulr = 7879; // a prime number; main() { int fin = 100; int i,j; int n=10000; int req[10000]; double moves[10000]; int seed = time(NULL)%1000; for (int run=0; run <50; run++) { int start=0; double movesum = 0.0; double average = 0.0; double variance = 0.0; double vsum = 0.0; clear(req,n); clear(moves,n); for (i=0; i<n; i++) // Generate n requests in req array { req[i]=rand(seed); j=abs(req[i]-start); moves[i]=double(j)/100.0;

movesum=movesum + moves[i]; start = req[i]; } average = movesum/double(n); for (i=0; i<n; i++) { double c = average-moves[i]; vsum = vsum + cc; } if (n>1) variance = vsum/double(n-1); cout << "Run = " << run; cout <<" movesum = "<<movesum<<" variance = "<<variance<<endl; } } int rand(int& s) // This generates random numbers between 0-99. { double u; s = (s * multip)% modulr; // compute new seed u = (100.0double(s))/double(modulr); return int(u); } void clear(double a[], int n) { for (int i=0; i<n ; i++) a[i]=0.0; } This is just FIFO disk-scheduling strategy. The output of the simulation appears to be uniformly distributed over variance as expected.