Saturday, 23 June 2012

c++ Program of first come first served (FCFS) scheduling algorithm

#include<iostream>
#include<fstream>
using namespace std;

int main()
{
    int  n,at,bt;
    char proc[200],file1[50];
    fstream my;
    cout<<"enter file name";
    cin.getline(file1,50);
    my.open(file1,ios::out);
    cout<<"how many";
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cout<<"enter process:";
        cin>>proc;
        cout<<"enter arrival time";
        cin>>at;
        cout<<"enter burst time;";
        cin>>bt;
        my<<proc<<endl<<at<<endl<<bt<<endl;
    }
    my.close();
   fstream myf;
    myf.open(file1,ios::in);
    char p[200];
    float arival;
    float  waiting=0;
    float brust;
    float totalw=0;
        for(float i=0;i<n;i++)
        {   
            waiting=waiting+(totalw-arival);
            cout<<"watiit"<<waiting<<endl;
            totalw=totalw+brust;           
        }
        float t=1.00;
        t = waiting/n;
    cout<<"n is"<<n;
    cout<<"average waiting time is"<<t;
    return 0;
    }
     

Various Process Scheduling Algorithms:

Various Page Replacement Algorithms:

Various Disk Head Movement Counting Algorithms: