Saturday, 17 November 2012
LRU Page Replacement Algo in C
FCFS Disk Scheduling Algo implementation in C++
#include<conio.h>
#include<stdlib.h>
//#include<time.h>
int request[100],st,cylinders,n;
//time_t t;
void random(void )
{
for(int i=0;i<n;i++)
{
//srand(request[(rand()%n)]);
request[i]=rand()%cylinders+1;
}
}
void display(void )
{
cout<<"\nThe requests are : \n";
for(int i=0;i<n;i++)
cout<<" "<<request[i]<<" ";
}
int main()
{
int choice;
void fcfs(void );
void scan(void );
cout<<"\nEnter no. of cylinders in hard disk and starting cylinder : ";
cin>>cylinders>>st;
cout<<"\npress 0 to generate random disk requests and any other no. to give your own requests : ";
cin>>choice;
if(choice==0)
{
cout<<"\nEnter no. of requests to generate randomly : ";
cin>>n;
random();
}
else
{
cout<<"\nEnter the cylinders requested (0 to break): \n";
while(1)
{
cin>>request[n++];
if(request[n-1]==0||n==100)
{
n--;
break;
}
}
}
cout<<"\nEnter the scheduling algo that you want to implement(0:FCFS,1:Scan) : ";
cin>>choice;
switch(choice)
{
case 0:
fcfs();
break;
case 1:
scan();
break;
default:
break;
}
getch();
return 0;
}
void fcfs(void )
{
int total=0,i; //no of cylinders traversed
display();
cout<<"\n\n The traversal is shown below : \n\n"<<st;
for(i=0;i<n;i++)
{
cout<<"-->"<<request[i];
total=total+abs(request[i]-st);
st=request[i];
}
cout<<"\n\nNo. of cylinders traversed : "<<total;
}
void scan(void )
{
int total=0,i,j,temp;
display();
for(i=0;i<n;i++)
for(j=0;j<n-1-i;j++)
{
if(request[j]>request[j+1])
{
temp=request[j];
request[j]=request[j+1];
request[j+1]=temp;
}
}
display();
cout<<" \nThe traversal is shown below : \n\n"<<st;
if(st<request[0])
{
for(i=0;i<n;i++)
{
cout<<"-->"<<request[i];
total+=abs(request[i]-st);
st=request[i];
}
}
else
{
i=0;
temp=0;
while(st>request[i++])
temp++;
for(i=temp;i<n;i++)
{
cout<<"-->"<<request[i];
total+=abs(request[i]-st);
st=request[i];
if(i==n-1)
{
total=total+2*cylinders-request[i];
st=0;
i=0;
n=temp;
if(st!=cylinders)
{
cout<<"-->"<<cylinders;
cout<<"-->"<<1;
}
}
}
}
cout<<"\nTotal cylinders traversed : "<<total;
}
Saturday, 3 November 2012
What Is A Leader????
Yes what is a leader.
Some might think as a strange question but my question is correct.
Leader : A term which in our dictionary refers to 40+ old aged person who carries with himself his experience and knowledge who can tackle difficulties.
But Is he actually worthy of being called a Leader I doubt ?
We often see such characteristics in leader but the reverse is just true.
All those 40+ old mangers who are being talked of are just the power in position.A leader is one who inspire and motivates !!!!! Ya a bit bookish.
Lets simplfy In terms of Aditya Dua you are not a leader :
1.If you take the credit of your win.
2.If you fail you blame your team
3.If you believe you should head the team
4.If you believe you can get the work done by anger.
A person who heads the team is actually just a power head he may or may not be a good leader.
A leader is one who takes responsibility of all the failures that happens but forwards his teammates when it comes to collecting laurels.Even a junior level person in a team may be a leader because it requires skills of composure and able to tackle problems.
Dont worry I am not a leader I am doing just what I wish to convey
Sunday, 26 August 2012
Sunday, 10 June 2012
Dhirubhai Ambani : My Hero
Dhirubhai Ambani : Story Of THE LEGEND
Source : http://www.successstories.co.in/dhirubhai-ambani-a-real-rags-to-riches-story.
copyright protected by : successstories.co.in
Sunday, 1 April 2012
Success is not a destination it is a journey
Success??????
We often hear that people boasting about I am successfull but is success really a destination ? If yes then
reliance would have never been a multi millionare bussiness house,
apple would have stopped after macintosh os,
there would have been no infosys,
Because as far as we feel we treat success is as destination but have u ever imagined after ur success in one project we tend to move on another project with more confidence and zeal our ultimate goal is far off and to our surprise that ultimate goal is also not our destination that is also the step to another goal which is much wider and better.
Who says failure is opposite to success ? In my observation failure is nothing but getting close to success.don't work to be successful work because you want to. It is often seen that when we work to be successfull we waste our time thinking about goal so guys just work because u think u want to work. When u focus on work u attain small success in terms of short goals that makes ur path comfortable and easy.
Let me narrate a story :
Once a 5 year child went to his guru to attain knowledge.
He asked him :
Guruji how much time will take to complete my education ?
The teacher replied him : 5 yrs if u practise 8 hrs a day.
The students asked : wht if I practise 16 hrs a day?
The teacher replied : 10 yrs
The student out of tension asked : if I study 24 hrs a day?
the guru replied : 20 yrs.....
The boy thought and asked when I am devoting more time then why r u increasing my time of education :
The guru told : son ! When u foucs on time then u tend to waste your time watching time and hence you go back one step from your goal.
Moral : when u want to achieve something in life then don't wait fr time jst start and time will follow u
Friday, 30 March 2012
Agr sapne na hote to zindagi kitne adhori hoti
Agr sapne na hote
to
zindagi kitne adhori hoti
Na ye lambi lambi raten hoti
Na ye din me ye bhagam bhaag hoti
Agr sapne na hote to zindagi kitne adhori hoti
Na kuch pane ki khushi hoti
Na kuch khone ka gam hota....
Na hi zindagi me phele ane ki jung hoti
Agr sapne na hote to zindagi kitne adhori hoti
na hi hume kuch jeetne ki tamana hoti
Na hi hume kuch paana ki echa hoti
Hum aj bhi ghodhe aur gahde chala rahe hote
Technology ke naam par cycle hoti
haath mein android nahi purne jamane ki pen hoti
Agar sapne na hote to ye blog nahi purno ki kitabe hoti
Agr sapne na hote to zindagi kitne adhori hoti
Sapne na hote to hame chaan ki neeend milte
Kyunki sapne vo nahi jo hum so kar dekhte hain
Sapne to vo hote hain jo apko sone nahi dete....
Agr sapne na hote to zindagi kitni adhori hoti