Showing posts with label operating system program. Show all posts
Showing posts with label operating system program. Show all posts

Wednesday 27 June 2012

c++ program to implement non-preemitive Shortest job first (SJF) scheduling algorithm using function

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{
    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {
       
        cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";

c++ program to implement preemitive Priority based scheduling algorithm using function.

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {    cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";
        cin>>b;
        cout<<endl<<"enter prority time:";
        cin>>p;

c++ program to implement non-preemitive Shortest job first (SJF) scheduling algorithm using function

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{
    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {
       
        cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";

c++ program to implement non- preemitive Priority based scheduling algorithm using function.

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {    cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";
        cin>>b;
        cout<<endl<<"enter prority time:";
        cin>>p;

Sunday 24 June 2012

c++ program to count total number of head movement using c- loop scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,lrem [5],t;
int rrem[5],prev=ub,current=0,qsize=n,lrsize=0,rrsize=0;
 

c++ program to count total number of head movement using loop scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;

c++ program to count total number of head movement using c-scan scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;

c++ program to count total number of head movement using scan scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,lrem [5],t;
int rrem[5],prev=ub,current=0,qsize=n,lrsize=0,rrsize=0;
    for(i=0;i<n;i++)
    {

c++ program to count total number of head movement using Shortest seek job first(SSJF) scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;

c++ program to count total number of head movement using first come first served(FCFS) scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
    int n;
    cout<<"enter your queue size:";
    cin>>n;
    int ub,lb=0;
    cout<<"Enter your upper bound:";
    cin>>ub;
    int queue[3];
    int head;
    cout<<"Enter your head:";
    cin>>head;

c++ program to performed Page replacement using First Come First Served (FCFS) technique.

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<conio.h>

int main()
{
char c[12];
int size=3,fpoint=0,top=0;
int frame[3],stack[3];
cout<<"enter your string:";
cin>>c;
int i,j,val,flag=0,temp,fault=0;

c++ program to perform Page replacement using Least Recently Used (LRU) technique.

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

int main()
{
char c[12];
int size=3,fpoint=0,top=0;
int frame[3],stack[3];
cout<<"enter your string:";
cin>>c;
int i,j,val,flag=0,temp,fault=0;
for(i=0;c[i]!='\0';i++)
{

c++ program of Round Robin scheduling algorithm.

#include<iostream.h>
#include<stdio.h>
#include<fstream.h>

int main()
{    int n=3;
    float total,wait[3]={0};
    float p[3],twaiting=0,waiting=0;
    int proc;
    int stack[3];
    float brust[3],arrival[3],sbrust,temp[3],top=3;
    for(int j=0;j<n;j++)
    {
   

Saturday 23 June 2012

c++ program of preemitive Shortest job first (SJF) scheduling algorithm.

#include<iostream.h>
#include<stdio.h>
int main()
{    int n=3;
    float total,wait[3]={0};
    float p[3],twaiting=0,waiting=0;
    int proc;
    int stack[3];
    float brust[3],arrival[3],sbrust,temp[3],top=3;
    for(int i=0;i<n;i++)
    {
        p[i]=i;
        stack[i]=i;
        cout<<"enter arival time :";
        cin>>arrival[i];
        cout<<endl<<"enter brust time:";
        cin>>brust[i];
        temp[i]=arrival[i];
        sbrust=brust[i]+sbrust;
    }   

c++ program of preemitive prority based scheduling algorithm.

#include <iostream>
using namespace std;
int main()
{    int n;
    cout<<"enter your toal no. of process";
    cin>>n;
    float total,wait[n];
    float p[n],twaiting=0,waiting=0;
    int proc;
    int stack[n];
    float brust[n],arrival[n],sbrust,temp[n],top=n,prority[n];
    int i;
   

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:
                                  

Friday 22 June 2012

c++ program of non preemptive priority based scheduling algorithm

#include <iostream>
using namespace std;


int main()
{    int n;

    cout<<"enter your toal no. of process";
    cin>>n;
    float total,wait[n];
    float p[n],twaiting=0,waiting=0;
    int proc;
    int stack[n];
    float brust[n],arrival[n],sbrust,temp[n],top=n,prority[n];
    int i;
    for(i=0;i<n;i++)
    {
        p[i]=i;
        stack[i]=i;
        cout<<"enter arival time :";
        cin>>arrival[i];
        cout<<endl<<"enter brust time:";
        cin>>brust[i];
        cout<<endl<<"enter prority time:";
        cin>>prority[i];
       
        temp[i]=arrival[i];
        sbrust=brust[i]+sbrust;
             
    }
   
    for(i=0;i<sbrust;i++)
    {   
        //section 1
        proc=stack[0];
        if(temp[proc]==i)
        {
         
            twaiting=0;
        }
        else
        {   
            twaiting=i-(temp[proc]);
         }
           temp[proc]=i+1;   
           wait[proc]=wait[proc]+twaiting;
            waiting=waiting+(twaiting);
            brust[proc]=brust[proc]-1;
                          
        if(brust[proc]==0)
        {
            for(int x=0;x<top-1;x++)
            {
                stack[x]=stack[x+1];
              
            }
            top=top-1;
    
       
        for(int z=0;z<top-1;z++)
        {  
            if((prority[stack[0]]>prority[stack[z+1]]) && (arrival[stack[z+1]] <= i+1))
            {
                   int t=stack[0];
            stack[0]=stack[z+1];
            stack[z+1]=t;
            }
       
        }
           
        }
       
       
    }


cout<<"Average waiting time is:"<<waiting/n;
float tu=(sbrust+waiting)/n;
cout<<endl<<"Average turnaround time is:"<<tu;
return 0;
}




Various Process Scheduling Algorithms:

Various Page Replacement Algorithms:

Various Disk Head Movement Counting Algorithms:

c++ program of non preemptive Shortest Job First (SJF)scheduling algorithm

#include<iostream.h>
#include<stdio.h>
#include<fstream.h>

int main()
{    int n=3;
    float total,wait[3]={0};
    float p[3],twaiting=0,waiting=0;
    int proc;
    int stack[3];
    float brust[3],arrival[3],sbrust,temp[3],top=3;

for(int i=0;i<n;i++)
    {
        p[i]=i;
        stack[i]=i;
        cout<<"enter arival time :";
        cin>>arrival[i];
        cout<<endl<<"enter brust time:";
        cin>>brust[i];
        temp[i]=arrival[i];
        sbrust=brust[i]+sbrust;
       
       
    }
   
    for(i=0;i<sbrust;i++)
    {
        proc=stack[0];
        if(temp[proc]==i)
        {
            //temp[proc]=i+1;;
            twaiting=0;
        }
        else
        {   
            twaiting=i-(temp[proc]);
                 
        }
        temp[proc]=i+1;   
  
        wait[proc]=wait[proc]+twaiting;
        waiting=waiting+(twaiting);
         brust[proc]=brust[proc]-1;
   
        if(brust[proc]==0)
        {
            for(int x=0;x<top-1;x++)
            {
                stack[x]=stack[x+1];
             }
            top=top-1;
            for(int z=0;z<top-1;z++)
            {  
                 if((brust[stack[0]]>brust[stack[z+1]]) && (arrival[stack[z+1]] <= i+1))
              {
                       int t=stack[0];
            stack[0]=stack[z+1];
            stack[z+1]=t;
              }
          }
        }
  
cout<<"waiting:"<<waiting;
return 0;
}


Various Process Scheduling Algorithms:

Various Page Replacement Algorithms:

Various Disk Head Movement Counting Algorithms: