SlideShare a Scribd company logo
1 of 8
To implement the concept of interprocess communication using pipes using c
program.
#include<stdio.h>
#include<unistd.h>
#include<string.h>
main()
{
int p1[2],p2[2],p3[2],p4[2];
int i,j=0,k=0,l=0;
char r[10],s[10],t[10],u[10];
printf("t PROCESS 1.ENTER THE STRING");
scanf("%s",r);
pipe(p1);
pipe(p2);
write(p1[1],r,sizeof(r));
write(p2[1],r,sizeof(r));
int a=fork();
if(a==0)
{
printf("nt PROCESS 2:it splits the given stringn");
read(p1[0],r,sizeof(r));
int n=strlen(r);
for(i=0;i<n/2;i++)
{
s[i]=r[i];
}
for(i=n/2;i<=n;i++)
{
t[j++]=r[i];
}
pipe(p3);
pipe(p4);
write(p3[1],s,sizeof(s));
write(p4[1],t,sizeof(t));
int b=fork();
if(b==0)
{
printf("p4 %dt",getpid());
printf("p2 %dn",getppid());
read(p3[0],s,sizeof(s));
printf("t PROCESS 4:sub string t %s t",s);
printf("no of char=%d n",strlen(s));
}
else
{
int c=fork();
if(c==0)
{
printf("p5 %dt",getpid());
printf("p2 %dn",getppid());
read(p4[0],t,sizeof(t));
printf("t PROCESS 5:sub string t %s t",t);
printf("no of char=%d n",strlen(t));
}
else
{
wait();
printf("p2 %dt",getpid());
printf("p1 %dn",getppid());
} }}
else
{
wait();
int d=fork();
if(d==0)
{
printf("p3 %dt",getpid());
printf("p1 %dn",getppid());
read(p2[0],r,sizeof(r));
for(i=strlen(r)-1;i>=0;i--)
{
u[l++]=r[i];
}
for(i=0;i<strlen(r);i++)
{
if(u[i]==r[i])
k++;
else
continue;
}
if(k==strlen(r))
printf("t PROCESS 3: the given string is palindromen");
else
printf("t PROCESS 3: the given string is not palindromen");
}
else
{
printf("p1 %dt",getpid());
printf("kernal %dtn",getppid());
}
}
}
To write aprogram to implement the FCFS scheduling algorithm
#include<stdio.h>
main()
{
int n,a[10],b[10],t[10],w[10],g[10],i,m;
float att=0,awt=0;
for(i=0;i<10;i++)
{
a[i]=0; b[i]=0; w[i]=0; g[i]=0;
}
printf("enter the number of process");
scanf("%d",&n);
printf("enter the burst times");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
printf("nenter the arrival times");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
g[0]=0;
for(i=0;i<10;i++)
g[i+1]=g[i]+b[i];
for(i=0;i<n;i++)
{
w[i]=g[i]-a[i];
t[i]=g[i+1]-a[i];
awt=awt+w[i];
att=att+t[i];
}
awt =awt/n;
att=att/n;
printf("ntprocesstwaiting timetturn arround timen");
for(i=0;i<n;i++)
{
printf("tp%dtt%dtt%dn",i,w[i],t[i]);
}
printf("the average waiting time is %fn",awt);
printf("the average turn around time is %fn",att);
}
c program for round robinnon preemptive cpuscheduling algorithm
#include<stdio.h>
void main()
{
int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
float avg_wt,avg_tat;
printf("Enter number of process:");
scanf("%d",&n);
printf("nEnter Burst Time:n");
for(i=0;i<n;i++)
{
printf("p%d:",i+1);
scanf("%d",&bt[i]);
p[i]=i+1; //contains process number
}
//sorting burst time in ascending order using selection sort
for(i=0;i<n;i++)
{
pos=i;
for(j=i+1;j<n;j++)
{
if(bt[j]<bt[pos])
pos=j;
}
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0; //waiting time for first process will be zero
//calculate waiting time
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
total+=wt[i];
}
avg_wt=(float)total/n; //average waiting time
total=0;
printf("nProcesst Burst Time tWaiting TimetTurnaround Time");
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i]; //calculate turnaround time
total+=tat[i];
printf("np%dtt %dtt %dttt%d",p[i],bt[i],wt[i],tat[i]);
}
avg_tat=(float)total/n; //average turnaround time
printf("nnAverage Waiting Time=%f",avg_wt);
printf("nAverage Turnaround Time=%fn",avg_tat);
}
write a c program to implement FIFO page replacement algorithm
#include<stdio.h>
int main()
{
int i,j,n,a[50],frame[10],no,k,avail,count=0;
printf("n ENTER THE NUMBER OF PAGES:n");
scanf("%d",&n);
printf("n ENTER THE PAGE NUMBER :n");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("n ENTER THE NUMBER OF FRAMES :");
scanf("%d",&no);
for(i=0;i<no;i++)
frame[i]= -1;
j=0;
printf("tref stringt page framesn");
for(i=1;i<=n;i++)
{
printf("%dtt",a[i]);
avail=0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
avail=1;
if (avail==0)
{
frame[j]=a[i];
j=(j+1)%no;
count++;
for(k=0;k<no;k++)
printf("%dt",frame[k]);
}
printf("n");
}
printf("Page Fault Is %d",count);
return 0;
}
To write ac program to implement LRUpage replacement algorithm
#include<stdio.h>
main()
{
int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20];
printf("Enter no of pages:");
scanf("%d",&n);
printf("Enter the reference string:");
for(i=0;i<n;i++)
scanf("%d",&p[i]);
printf("Enter no of frames:");
scanf("%d",&f);
q[k]=p[k];
printf("nt%dn",q[k]);
c++;
k++;
for(i=1;i<n;i++)
{
c1=0;
for(j=0;j<f;j++)
{
if(p[i]!=q[j])
c1++;
}
if(c1==f)
{
c++;
if(k<f)
{
q[k]=p[i];
k++;
for(j=0;j<k;j++)
printf("t%d",q[j]);
printf("n");
}
else
{
for(r=0;r<f;r++)
{
c2[r]=0;
for(j=i-1;j<n;j--)
{
if(q[r]!=p[j])
c2[r]++;
else
break;
}
}
for(r=0;r<f;r++)
b[r]=c2[r];
for(r=0;r<f;r++)
{
for(j=r;j<f;j++)
{
if(b[r]<b[j])
{
t=b[r];
b[r]=b[j];
b[j]=t;
}
}
}
for(r=0;r<f;r++)
{
if(c2[r]==b[0])
q[r]=p[i];
printf("t%d",q[r]);
}
printf("n");
}
}
}
printf("nThe no of page faults is %d",c);
}

More Related Content

What's hot

ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
Unit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingUnit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingvrgokila
 
Groovify your java code by hervé roussel
Groovify your java code by hervé rousselGroovify your java code by hervé roussel
Groovify your java code by hervé rousselHervé Vũ Roussel
 
C programming on the determination of shear force, bending moment, shear stre...
C programming on the determination of shear force, bending moment, shear stre...C programming on the determination of shear force, bending moment, shear stre...
C programming on the determination of shear force, bending moment, shear stre...Mamun Mehedee
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
Programs for Operating System
Programs for Operating SystemPrograms for Operating System
Programs for Operating SystemLPU
 
C & Python Introduction
C & Python IntroductionC & Python Introduction
C & Python IntroductionSpy Seat
 

What's hot (17)

Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
test
testtest
test
 
Unit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingUnit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programming
 
บทที่ 3
บทที่ 3บทที่ 3
บทที่ 3
 
Tools.cpp
Tools.cppTools.cpp
Tools.cpp
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Groovify your java code by hervé roussel
Groovify your java code by hervé rousselGroovify your java code by hervé roussel
Groovify your java code by hervé roussel
 
C programming on the determination of shear force, bending moment, shear stre...
C programming on the determination of shear force, bending moment, shear stre...C programming on the determination of shear force, bending moment, shear stre...
C programming on the determination of shear force, bending moment, shear stre...
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sort
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
Programs for Operating System
Programs for Operating SystemPrograms for Operating System
Programs for Operating System
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
C programming
C programmingC programming
C programming
 
Forkexpe
ForkexpeForkexpe
Forkexpe
 
C & Python Introduction
C & Python IntroductionC & Python Introduction
C & Python Introduction
 

Viewers also liked

Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...
Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...
Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...windi silviana
 
Adliner Anews 2017
Adliner Anews 2017Adliner Anews 2017
Adliner Anews 2017adliner
 
3Com 655000201
3Com 6550002013Com 655000201
3Com 655000201savomir
 
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...contactOpinionWay
 

Viewers also liked (9)

Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...
Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...
Sim, windi silviana, hapzi ali, sistem pengambilan keputusan, universitas mer...
 
Adliner Anews 2017
Adliner Anews 2017Adliner Anews 2017
Adliner Anews 2017
 
Making a lesson plan
Making a lesson planMaking a lesson plan
Making a lesson plan
 
3Com 655000201
3Com 6550002013Com 655000201
3Com 655000201
 
Calendario Ass. Mon'Do'
Calendario Ass. Mon'Do'Calendario Ass. Mon'Do'
Calendario Ass. Mon'Do'
 
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...
Opinionway pour l'Agence du Don en Nature - Générosité et consommation / Mars...
 
Цитатна доріжка
 Цитатна доріжка Цитатна доріжка
Цитатна доріжка
 
Jmmatthewslaw
JmmatthewslawJmmatthewslaw
Jmmatthewslaw
 
Deep freezer
Deep freezerDeep freezer
Deep freezer
 

Similar to Os scheduling Algorithms

Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanriturajj
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start sedalipkumar64
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functionsAwinash Goswami
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...DR B.Surendiran .
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
C basics
C basicsC basics
C basicsMSc CST
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Dr. Loganathan R
 
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docx
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docxShad_Cryptography_PracticalFile_IT_4th_Year (1).docx
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docxSonu62614
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using cArghodeepPaul
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Dr. Loganathan R
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CEleanor McHugh
 

Similar to Os scheduling Algorithms (20)

programs
programsprograms
programs
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functions
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
C basics
C basicsC basics
C basics
 
C Programming
C ProgrammingC Programming
C Programming
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docx
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docxShad_Cryptography_PracticalFile_IT_4th_Year (1).docx
Shad_Cryptography_PracticalFile_IT_4th_Year (1).docx
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
c programs.pptx
c programs.pptxc programs.pptx
c programs.pptx
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 

More from Neelamani Samal

Fault Tolerance token Based Algorithm
Fault Tolerance token Based AlgorithmFault Tolerance token Based Algorithm
Fault Tolerance token Based AlgorithmNeelamani Samal
 
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...Neelamani Samal
 
computer architecture lab manual
computer architecture lab manualcomputer architecture lab manual
computer architecture lab manualNeelamani Samal
 
Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Neelamani Samal
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab ManualNeelamani Samal
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering noteNeelamani Samal
 
Lamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusionLamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusionNeelamani Samal
 
How to install windows Xp sp2
How to install windows Xp sp2How to install windows Xp sp2
How to install windows Xp sp2Neelamani Samal
 
Game Playing In A I Final
Game  Playing In  A I  FinalGame  Playing In  A I  Final
Game Playing In A I FinalNeelamani Samal
 

More from Neelamani Samal (16)

Fault Tolerance token Based Algorithm
Fault Tolerance token Based AlgorithmFault Tolerance token Based Algorithm
Fault Tolerance token Based Algorithm
 
RTS Question Paper 2012
RTS Question Paper 2012RTS Question Paper 2012
RTS Question Paper 2012
 
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
computer architecture lab manual
computer architecture lab manualcomputer architecture lab manual
computer architecture lab manual
 
Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab Manual
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering note
 
Values oflife
Values oflifeValues oflife
Values oflife
 
Attitute
AttituteAttitute
Attitute
 
Cd writning technology
Cd writning technologyCd writning technology
Cd writning technology
 
Turing machine
Turing machineTuring machine
Turing machine
 
Lamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusionLamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusion
 
How to install windows Xp sp2
How to install windows Xp sp2How to install windows Xp sp2
How to install windows Xp sp2
 
Game Playing In A I Final
Game  Playing In  A I  FinalGame  Playing In  A I  Final
Game Playing In A I Final
 
Computer Brain Power
Computer Brain PowerComputer Brain Power
Computer Brain Power
 

Recently uploaded

Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxNadaHaitham1
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 

Recently uploaded (20)

Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 

Os scheduling Algorithms

  • 1. To implement the concept of interprocess communication using pipes using c program. #include<stdio.h> #include<unistd.h> #include<string.h> main() { int p1[2],p2[2],p3[2],p4[2]; int i,j=0,k=0,l=0; char r[10],s[10],t[10],u[10]; printf("t PROCESS 1.ENTER THE STRING"); scanf("%s",r); pipe(p1); pipe(p2); write(p1[1],r,sizeof(r)); write(p2[1],r,sizeof(r)); int a=fork(); if(a==0) { printf("nt PROCESS 2:it splits the given stringn"); read(p1[0],r,sizeof(r)); int n=strlen(r); for(i=0;i<n/2;i++) { s[i]=r[i]; } for(i=n/2;i<=n;i++) { t[j++]=r[i]; } pipe(p3); pipe(p4); write(p3[1],s,sizeof(s)); write(p4[1],t,sizeof(t)); int b=fork(); if(b==0) { printf("p4 %dt",getpid()); printf("p2 %dn",getppid()); read(p3[0],s,sizeof(s)); printf("t PROCESS 4:sub string t %s t",s); printf("no of char=%d n",strlen(s)); }
  • 2. else { int c=fork(); if(c==0) { printf("p5 %dt",getpid()); printf("p2 %dn",getppid()); read(p4[0],t,sizeof(t)); printf("t PROCESS 5:sub string t %s t",t); printf("no of char=%d n",strlen(t)); } else { wait(); printf("p2 %dt",getpid()); printf("p1 %dn",getppid()); } }} else { wait(); int d=fork(); if(d==0) { printf("p3 %dt",getpid()); printf("p1 %dn",getppid()); read(p2[0],r,sizeof(r)); for(i=strlen(r)-1;i>=0;i--) { u[l++]=r[i]; } for(i=0;i<strlen(r);i++) { if(u[i]==r[i]) k++; else continue; } if(k==strlen(r)) printf("t PROCESS 3: the given string is palindromen"); else printf("t PROCESS 3: the given string is not palindromen"); } else { printf("p1 %dt",getpid()); printf("kernal %dtn",getppid());
  • 3. } } } To write aprogram to implement the FCFS scheduling algorithm #include<stdio.h> main() { int n,a[10],b[10],t[10],w[10],g[10],i,m; float att=0,awt=0; for(i=0;i<10;i++) { a[i]=0; b[i]=0; w[i]=0; g[i]=0; } printf("enter the number of process"); scanf("%d",&n); printf("enter the burst times"); for(i=0;i<n;i++) scanf("%d",&b[i]); printf("nenter the arrival times"); for(i=0;i<n;i++) scanf("%d",&a[i]); g[0]=0; for(i=0;i<10;i++) g[i+1]=g[i]+b[i]; for(i=0;i<n;i++) { w[i]=g[i]-a[i]; t[i]=g[i+1]-a[i]; awt=awt+w[i];
  • 4. att=att+t[i]; } awt =awt/n; att=att/n; printf("ntprocesstwaiting timetturn arround timen"); for(i=0;i<n;i++) { printf("tp%dtt%dtt%dn",i,w[i],t[i]); } printf("the average waiting time is %fn",awt); printf("the average turn around time is %fn",att); } c program for round robinnon preemptive cpuscheduling algorithm #include<stdio.h> void main() { int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp; float avg_wt,avg_tat; printf("Enter number of process:"); scanf("%d",&n); printf("nEnter Burst Time:n"); for(i=0;i<n;i++) { printf("p%d:",i+1); scanf("%d",&bt[i]); p[i]=i+1; //contains process number } //sorting burst time in ascending order using selection sort for(i=0;i<n;i++) {
  • 5. pos=i; for(j=i+1;j<n;j++) { if(bt[j]<bt[pos]) pos=j; } temp=bt[i]; bt[i]=bt[pos]; bt[pos]=temp; temp=p[i]; p[i]=p[pos]; p[pos]=temp; } wt[0]=0; //waiting time for first process will be zero //calculate waiting time for(i=1;i<n;i++) { wt[i]=0; for(j=0;j<i;j++) wt[i]+=bt[j]; total+=wt[i]; } avg_wt=(float)total/n; //average waiting time total=0; printf("nProcesst Burst Time tWaiting TimetTurnaround Time"); for(i=0;i<n;i++) { tat[i]=bt[i]+wt[i]; //calculate turnaround time total+=tat[i]; printf("np%dtt %dtt %dttt%d",p[i],bt[i],wt[i],tat[i]); } avg_tat=(float)total/n; //average turnaround time printf("nnAverage Waiting Time=%f",avg_wt); printf("nAverage Turnaround Time=%fn",avg_tat); }
  • 6. write a c program to implement FIFO page replacement algorithm #include<stdio.h> int main() { int i,j,n,a[50],frame[10],no,k,avail,count=0; printf("n ENTER THE NUMBER OF PAGES:n"); scanf("%d",&n); printf("n ENTER THE PAGE NUMBER :n"); for(i=1;i<=n;i++) scanf("%d",&a[i]); printf("n ENTER THE NUMBER OF FRAMES :"); scanf("%d",&no); for(i=0;i<no;i++) frame[i]= -1; j=0; printf("tref stringt page framesn"); for(i=1;i<=n;i++) { printf("%dtt",a[i]); avail=0; for(k=0;k<no;k++) if(frame[k]==a[i]) avail=1; if (avail==0) { frame[j]=a[i]; j=(j+1)%no; count++; for(k=0;k<no;k++) printf("%dt",frame[k]); } printf("n"); } printf("Page Fault Is %d",count); return 0; }
  • 7. To write ac program to implement LRUpage replacement algorithm #include<stdio.h> main() { int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20]; printf("Enter no of pages:"); scanf("%d",&n); printf("Enter the reference string:"); for(i=0;i<n;i++) scanf("%d",&p[i]); printf("Enter no of frames:"); scanf("%d",&f); q[k]=p[k]; printf("nt%dn",q[k]); c++; k++; for(i=1;i<n;i++) { c1=0; for(j=0;j<f;j++) { if(p[i]!=q[j]) c1++; } if(c1==f) { c++; if(k<f) { q[k]=p[i]; k++; for(j=0;j<k;j++) printf("t%d",q[j]); printf("n"); } else { for(r=0;r<f;r++) { c2[r]=0; for(j=i-1;j<n;j--) { if(q[r]!=p[j])