SlideShare a Scribd company logo
1 of 18
Operating System [CS-502]
Lab Manual
Session July- 2012
a) FCFS:
AIM: A program to simulate the FCFS CPU scheduling algorithm.
ALGORITHM:
Step 1: Start the program.
Step 2: Read the needed variables and the number of process.
Step 3: Read the burst time for all process.
Step 4: Read the arrival time (AT).
Step 5: Calculate the waiting time and turn around time and display it.
Step 6: Calculate the average waiting time and average total turnaround time and display it.
Step 7: Stop the program.
PROGRAM:
#include<stdio.h>
#include<string.h>
#include<conio.h>
main()
{
char pn[10][10],t[10];
int arr[10],bur[10],star[10],finish[10],tat[10],wt[10],i,j,n,temp;
int totwt=0,tottat=0;
//clrscr();
printf("Enter the number of processes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the Process Name, Arrival Time & Burst Time:");
scanf("%s%d%d",&pn[i],&arr[i],&bur[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
temp=bur[i];
bur[i]=bur[j];
bur[j]=temp;
strcpy(t,pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],t);
}
}
}
for(i=0;i<n;i++)
{
if(i==0)
star[i]=arr[i];
else
star[i]=finish[i-1];
wt[i]=star[i]-arr[i];
finish[i]=star[i]+bur[i];
tat[i]=finish[i]-arr[i];
}
printf("nPName Arrtime Burtime WaitTime Start TAT Finish");
for(i=0;i<n;i++)
{
printf("n%st%3dt%3dt%3dt%3dt%6dt%6d",pn[i],arr[i],bur[i],wt[i],star[i],tat[i],finish[i]);
totwt+=wt[i];
tottat+=tat[i];
}
printf("nAverage Waiting time:%f",(float)totwt/n);
printf("nAverage Turn Around Time:%f",(float)tottat/n);
getch();
return 0;
}
OUTPUT:
Enter the number of processes: 3
Enter the Process Name, Arrival Time & Burst Time: p1 2 4
Enter the Process Name, Arrival Time & Burst Time: p2 3 5
Enter the Process Name, Arrival Time & Burst Time: p3 1 6
PName Arrtime Burtime WaitTime Strart TAT Finish
p3 1 6 0 1 6 7
p1 2 4 5 7 9 11
p2 3 5 8 11 13 16
Average Waiting Time: 4.3333333
Average Turn Around Time: 9.33333333
Q.1What is CPU scheduling?
Q.2What is turnaround time?
Q.3What is waiting time?
b) SJF:
AIM: A program to simulate the SJF CPU scheduling algorithm
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the variable.
Step 3: Read the value of n.
Step 4: Scan the value of p[i] for i=1 to i
Step 5: Read the value of at and print the value of at.
Step 6: Do step 7 for i=1 to i
Step 7: Do step 8 for j=j+1 to j<=n and increment j value by 1.
Step 8: if p[i]>p[j], then assign t=p[j] and p[j]=p[i],then p[i]=t.
Step 9: Assign w[j]=at,at=at+p[i].
Step 10: Print the value at.
Step 11: Do step 8 for i=1,i<=n and increment value of i by 1.
Step 12: Assign sum=sum+w[i] and print the value of w[i].
Step 13: Assign avg=sum/n then print the value of avg.
Step 14: Print the value of i and p[i],w[i].
Step 15: Assign avg1=sum1/n and print the value of avg1.
Step 16: Stop the program.
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int et[20],at[10],n,i,j,temp,st[10],ft[10],wt[10],ta[10];
int totwt=0,totta=0;
float awt,ata;
char pn[10][10],t[10];
clrscr();
printf("Enter the number of process:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter process name, arrival time & execution time:");
flushall();
scanf("%s%d%d",pn[i],&at[i],&et[i]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
if(et[i]<et[j])
{
temp=at[i];
at[i]=at[j];
at[j]=temp;
temp=et[i];
et[i]=et[j];
et[j]=temp;
strcpy(t,pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],t);
}
}
for(i=0;i<n;i++)
{
if(i==0)
st[i]=at[i];
else
st[i]=ft[i-1];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
totwt+=wt[i];
totta+=ta[i];
}
awt=(float)totwt/n;
ata=(float)totta/n;
printf("nPnametarrivaltimetexecutiontimetwaitingtimettatime");
for(i=0;i<n;i++)
printf("n%st%5dtt%5dtt%5dtt%5d",pn[i],at[i],et[i],wt[i],ta[i]);
printf("nAverage waiting time is:%f",awt);
printf("nAverage turnaroundtime is:%f",ata);
getch();
}
OUTPUT:
Enter the number of processes: 3
Enter the Process Name, Arrival Time & Burst Time: 1 4 6
Enter the Process Name, Arrival Time & Burst Time: 2 5 15
Enter the Process Name, Arrival Time & Burst Time: 3 6 11
Pname arrivaltime executiontime waitingtime tatime
1 4 6 0 6
3 6 11 4 15
2 5 15 16 31
Average Waiting Time: 6.6667
Average Turn Around Time: 17.3333
Q.1What is the use of CPU scheduling?
Q.2What is burst time?
Q.3What is SJF CPU scheduling?
c) Priority:
AIM: A program to simulate the priority CPU scheduling algorithm
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the variables as required.
Step 3: Get the number of process.
Step 4: Get the burst time for each process.
Step 5: get the ID value for each process.
Step 6: Get the arrival time for each process.
Step 7: Using the read data find the waiting time and turnaround time and average turn around
time and print the result.
Step 8: Stop the program.
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int et[20],at[10],n,i,j,temp,p[10],st[10],ft[10],wt[10],ta[10];
int totwt=0,totta=0;
float awt,ata;
char pn[10][10],t[10];
clrscr();
printf("Enter the number of process:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter process name,arrivaltime,execution time & priority:");
flushall();
scanf("%s%d%d%d",pn[i],&at[i],&et[i],&p[i]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
if(p[i]<p[j])
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
temp=at[i];
at[i]=at[j];
at[j]=temp;
temp=et[i];
et[i]=et[j];
et[j]=temp;
strcpy(t,pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],t);
}
}
for(i=0;i<n;i++)
{
if(i==0)
{
st[i]=at[i];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}
else
{
st[i]=ft[i-1];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}
totwt+=wt[i];
totta+=ta[i];
}
awt=(float)totwt/n;
ata=(float)totta/n;
printf("nPnametarrivaltimetexecutiontimetprioritytwaitingtimettatime");
for(i=0;i<n;i++)
printf("n%st%5dtt%5dtt%5dtt%5dtt%5d",pn[i],at[i],et[i],p[i],wt[i],ta[i]);
printf("nAverage waiting time is:%f",awt);
printf("nAverage turnaroundtime is:%f",ata);
getch();
}
OUTPUT:
Enter the number of processes: 3
Enter the Process Name, Arrival Time, execution time & priority: 1 2 3 1
Enter the Process Name, Arrival Time, execution time & priority: 2 4 5 2
Enter the Process Name, Arrival Time, execution time & priority: 3 5 6 3
Pname arrivaltime executiontime priority waitingtime tatime
1 2 3 1 0 3
2 4 5 2 1 6
3 5 6 3 5 11
Average Waiting Time: 2.0000
Average Turn Around Time: 6.6667
Q.1What is Priority CPU scheduling?
Q.2What is the advantage of Priority CPU scheduling.
d) Round Robin:
AIM: A program to simulate the Round Robin CPU scheduling algorithm
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the variables as required.
Step 3: Get the number of process.
Step 4: Get the burst time for each process.
Step 5: get the quantum value.
Step 6: Get the arrival time for each process.
Step 7: Using the read data find the waiting time and turnaround time and average turn around time
and print the result.
Step 8: Stop the program.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int et[30],ts,n,i,x=0,tot=0;
char pn[10][10];
clrscr();
printf("Enter the no of processes:");
scanf("%d",&n);
printf("Enter the time quantum:");
scanf("%d",&ts);
for(i=0;i<n;i++)
{
printf("enter process name & estimated time:");
scanf("%s %d",pn[i],&et[i]);
}
printf("The processes are:");
for(i=0;i<n;i++)
printf("process %d: %sn",i+1,pn[i]);
for(i=0;i<n;i++)
tot=tot+et[i];
while(x!=tot)
{
for(i=0;i<n;i++)
{
if(et[i]>ts)
{
x=x+ts;
printf("n %s -> %d",pn[i],ts);
et[i]=et[i]-ts;
}
else
if((et[i]<=ts)&&et[i]!=0)
{
x=x+et[i];
printf("n %s -> %d",pn[i],et[i]);
et[i]=0;}
}
}
printf("n Total Estimated Time:%d",x);
getch();
}
OUTPUT:
Enter the no of processes: 2
Enter the time quantum: 3
Enter the process name & estimated time: p1 12
Enter the process name & estimated time: p2 15
p1 -> 3
p2 -> 3
p1 -> 3
p2 -> 3
p1 -> 3
p2 -> 3
p1 -> 3
p2 -> 3
p2 -> 3
Total Estimated Time: 27
Q.1What is Round Robin CPU scheduling?
Q.2What is the advantage of Round robin CPU scheduling?
5-AIM:To write a C program for implementing Producer Consumer problem using Semaphore.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the choice 1 for Producer, 2 for Consumer.
Step 3: If the choice is 1, the produced buffer size is 1, again if the choice is 1 then buffer size
will be increased[produced buffer = 1 + 1 = 2].
Step 4: If the choice is 2, the consumed buffer size is 1.
Step 5: Stop the program.
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
//#include<process.h>
#define max 5
int n,produced,consumed,buffer[max];
int result,i;
int producer(int consumed,int result)
{
if((consumed=1)&&(i>=0))
{
result=result+1;
i++;
buffer[i]=result;
produced=1;
printf("Produced bufffer=%dn",buffer[i]);
consumed=0;
return(produced,result);
}
else
printf("Buffer still to be consumedn");
}
int consumer(int produced,int result)
{
if((produced==1)&&(i>0))
{
consumed=1;
printf("Consumed buffer=%dn",buffer[i]);
produced=0;
i--;
return(consumed,result);
}
else
printf("Buffer still to be produced");
}
int main()
{
clrscr();
produced=0;
consumed=1;
result=0;
i=0;
while(1)
{
printf("Enter the choicen");
printf("1.Producer 2.Consumer 3.Exitn");
scanf("%d",&n);
if(n==3)
exit(0);
else if(n==1)
producer(consumed,buffer[i]);
else if(n==2)
consumer(produced,buffer[i]);
else
exit(0);
}
}
SAMPLE OUTPUT:
Enter the choice
1.Producer 2.Consumer 3.Exit
1
Produced Buffer = 1
Enter the choice
1.Producer 2.Consumer 3.Exit
1
Produced Buffer = 2
Enter the choice
1.Producer 2.Consumer 3.Exit
2
Consumed Buffer = 2
Enter the choice
1.Producer 2.Consumer 3.Exit
2
Consumed Buffer = 1
Enter the choice
1.Producer 2.Consumer 3.Exit
2
Buffer still to be produced
Enter the choice
1.Producer 2.Consumer 3.Exit
6-aim-wap to implement optimal page replacement algorithm
program:
#include<stdio.h>
#include<conio.h>
int fr[3];
void main()
{
void display();
int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3];
int max,found=0,lg[3],index,k,l,flag1=0,flag2=0,pf=0,frsize=3;
clrscr();
for(i=0;i<3;i++)
{
fr[i]=-1;
}
for(j=0;j<12;j++)
{
flag1=0;
flag2=0;
for(i=0;i<3;i++)
{
if(fr[i]==p[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i<3;i++)
{
if(fr[i]==-1)
{
fr[i]=p[j];
flag2=1;
break;
}
}
}
if(flag2==0)
{
for(i=0;i<3;i++)
lg[i]=0;
for(i=0;i<frsize;i++)
{
for(k=j+1;k<12;k++)
{
if(fr[i]==p[k])
{
lg[i]=k-j;
break;
}
}
}
found=0;
for(i=0;i<frsize;i++)
{
if(lg[i]==0)
{
index=i;
found=1;
break;
}
}
if(found==0)
{
max=lg[0];
index=0;
for(i=1;i<frsize;i++)
{
if(max<lg[i])
{
max=lg[i];
index=i;
}
}
}
fr[index]=p[j];
pf++;
}
display();
}
printf("n no of page faults:%d",pf);
getch();
}
void display()
{
int i;
printf("n");
for(i=0;i<3;i++)
printf("t%d",fr[i]);
}
output:
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 3 5
2 3 5
4 3 5
4 3 5
4 3 5
2 3 5
2 3 5
2 3 5
no of page fault:3
7) LRU:
AIM: A program to simulate LRU Page Replacement Algorithm
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int g=0,a[5],b[20],p=0,q=0,m=0,h,k,i,q1=1,j,u,n;
char f='F';
clrscr();
printf("Enter the number of pages:");
scanf("%d",&n);
printf("Enter %d Page Numbers:",n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<n;i++)
{if(p==0)
{
if(q>=3)
q=0;
a[q]=b[i];
q++;
if(q1<3)
{
q1=q;
//g=1;
}
}
printf("n%d",b[i]);
printf("t");
for(h=0;h<q1;h++)
printf("%d",a[h]);
if((p==0)&&(q<=3))
{
printf("-->%c",f);
m++;
}
p=0;
g=0;
if(q1==3)
{
for(k=0;k<q1;k++)
{
if(b[i+1]==a[k])
p=1;
}
for(j=0;j<q1;j++)
{
u=0;
k=i;
while(k>=(i-1)&&(k>=0))
{
if(b[k]==a[j])
u++;
k--;
}
if(u==0)
q=j;
}
}
else
{
for(k=0;k<q;k++)
{
if(b[i+1]==a[k])
p=1;
}
}
}
printf("nNo of faults:%d",m);
getch();
}
OUTPUT:
Enter the Number of Pages: 12
Enter 12 Page Numbers:
2 3 2 1 5 2 4 5 3 2 5 2
2 2-> F
3 23-> F
2 23
1 231-> F
5 251-> F
2 251
4 254-> F
5 254
3 354-> F
2 352-> F
5 352
2 352
No of faults: 7
Q.1-What is demand paging?
Q.2- Define LRU?
8) FIFO:
AIM: A program to simulate FIFO Page Replacement Algorithm
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],b[20],n,p=0,q=0,m=0,h,k,i,q1=1;
char f='F';
clrscr();
printf("Enter the Number of Pages:");
scanf("%d",&n);
printf("Enter %d Page Numbers:",n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<n; i++)
{if(p==0)
{
if(q>=3)
q=0;
a[q]=b[i];
q++;
if(q1<3)
{
q1=q;
}
}
printf("n%d",b[i]);
printf("t");
for(h=0;h<q1;h++)
printf("%d",a[h]);
if((p==0)&&(q<=3))
{
printf("-->%c",f);
m++;
}
p=0;
for(k=0;k<q1;k++)
{
if(b[i+1]==a[k])
p=1;
}
}
printf("nNo of faults:%d",m);
getch();
}
OUTPUT:
Enter the Number of Pages: 12
Enter 12 Page Numbers:
2 3 2 1 5 2 4 5 3 2 5 2
2 2-> F
3 23-> F
2 23
1 231-> F
5 531-> F
2 521-> F
4 524-> F
5 524
3 324-> F
2 324
5 354-> F
2 352-> F No of faults: 9
Q.1-What is the use of page replacement algorithm?
Q.2- What is page fault?
Q.3- Define FIFO page replacement algorithm?
Q.4- What is the advantage of FIFO?
9-AIM: A program to simulate Bankers Algorithm
PROGRAM:
// Bankers Algorithm- Systems Lab - C Program
#include<stdio.h>
#include<stdlib.h>
#define true 1
#define false 0
int m,n,i,j,count=0,process;
int max[10][10],alloc[10][10],need[10][10],c[10],avail[10],finish[10];
void readtable(int t[10][10])
{
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&t[i][j]);
}
void printtable(int t[10][10])
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("t%d",t[i][j]);
printf("n");
}
}
void readvector(int v[10])
{
for(j=0;j<n;j++)
scanf("%d",&v[j]);
}
void printvector(int v[10])
{
for(j=0;j<n;j++)
printf("t%d",v[j]);
}
void init()
{
printf("enter the number of processn");
scanf("%d",&m);
printf("enter the number of resourcesn");
scanf("%d",&n);
printf("enter the claim tablen");
readtable(max);
printf("enter the allocation tablen");
readtable(alloc);
printf("enter the max units of each resourcen");
readvector(c);
for(i=0;i<n;i++)
finish[i]=false;
}
void findavail()
{
int sum;
for(j=0;j<n;j++)
{
sum=0;
for(i=0;i<m;i++)
{
sum=sum+alloc[i][j];
}
avail[j]=c[j]-sum;
}
}
void findneed()
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
need[i][j]=max[i][j]-alloc[i][j];
}
}
}
void selectprocess()
{
int flag;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(need[i][j]<=avail[j])
flag=1;
else
{
flag=0;
break;
}
}
if((flag==1)&&(finish[i]==false))
{
process=i;
count++;
break;
}
}
printf("current status isn");
printtable(alloc);
if(flag==0)
{
printf("system is in unsafe staten");
exit(1);
}
printf("system is in safe state");
}
void executeprocess(int p)
{
printf("excuting process is %d",p);
printtable(alloc);
}
void releaseresource()
{
for(j=0;j<n;j++)
avail[j]=avail[j]+alloc[process][j];
for(j=0;j<n;j++)
{
alloc[process][j]=0;
need[process][j]=0;
}
}
Void main()
{
init();
findavail();
findneed();
do
{
selectprocess();
finish[process]=true;
executeprocess(process);
releaseresource();
}while(count<m);
printf("n all proces executed correctly");
}
OUTPUT:
enter the number of process
3
enter the number of resources
2
enter the claim table
0 0 1
1 1 0
enter the allocation table
1 1
0 1
1 0
enter the max units of each resource
2 2
current status is
1 1
0 1
1 0
system is in safe state excuting process is 0 1 1
0 1
1 0
current status is
0 0
0 1
1 0
system is in safe state excuting process is 1 0 0
0 1
1 0
current status is
0 0
0 0
1 0
system is in safe state excuting process is 2 0 0
0 0
1 0
all process executed correctly
Q.1- Explain Bankers algorithm
Q.2- What is deadlock.
Q.3- State the necessary condition for deadlock avoidance.

More Related Content

What's hot

What's hot (20)

Web Technology Lab File
Web Technology Lab FileWeb Technology Lab File
Web Technology Lab File
 
Strings
StringsStrings
Strings
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Strings in C
Strings in CStrings in C
Strings in C
 
Php session
Php sessionPhp session
Php session
 
Buffer Overflow Attacks
Buffer Overflow AttacksBuffer Overflow Attacks
Buffer Overflow Attacks
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in Python
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiArrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 

Viewers also liked (20)

Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
 
O.s. lab all_experimets
O.s. lab all_experimetsO.s. lab all_experimets
O.s. lab all_experimets
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Os file
Os fileOs file
Os file
 
work order of logic laboratory
work order of logic laboratory work order of logic laboratory
work order of logic laboratory
 
Lab2
Lab2Lab2
Lab2
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
Gun make
Gun makeGun make
Gun make
 
OS tutoring #1
OS tutoring #1OS tutoring #1
OS tutoring #1
 
FFmpeg
FFmpegFFmpeg
FFmpeg
 
Openssl
OpensslOpenssl
Openssl
 
Ooad lab manual
Ooad lab manualOoad lab manual
Ooad lab manual
 
Ooad lab manual(original)
Ooad lab manual(original)Ooad lab manual(original)
Ooad lab manual(original)
 
ipv6 introduction & environment buildup
ipv6 introduction & environment buildupipv6 introduction & environment buildup
ipv6 introduction & environment buildup
 
UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015
UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015
UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
DBMS Practical File
DBMS Practical FileDBMS Practical File
DBMS Practical File
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
Memory reference instruction
Memory reference instructionMemory reference instruction
Memory reference instruction
 

Similar to Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)

Similar to Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search) (20)

Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
Os lab upto_1st_mid
Os lab upto_1st_midOs lab upto_1st_mid
Os lab upto_1st_mid
 
Os lab upto 1st mid
Os lab upto 1st midOs lab upto 1st mid
Os lab upto 1st mid
 
Operating system labs
Operating system labsOperating system labs
Operating system labs
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
C file
C fileC file
C file
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C
CC
C
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Operating System Lab Manual
Operating System Lab ManualOperating System Lab Manual
Operating System Lab Manual
 
Hargun
HargunHargun
Hargun
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Bankers Algo Implementation
Bankers Algo ImplementationBankers Algo Implementation
Bankers Algo Implementation
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 

More from Make Mannan

Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problemsMake Mannan
 
Earth quake failures best
Earth quake failures bestEarth quake failures best
Earth quake failures bestMake Mannan
 
Engineering Graphics Drawing PPT : Download above File and Click on each topi...
Engineering Graphics Drawing PPT : Download above File and Click on each topi...Engineering Graphics Drawing PPT : Download above File and Click on each topi...
Engineering Graphics Drawing PPT : Download above File and Click on each topi...Make Mannan
 
Geo technical Geotech. Soil Mechanics : Download above File and Click on eac...
Geo technical Geotech. Soil Mechanics : Download above File and Click  on eac...Geo technical Geotech. Soil Mechanics : Download above File and Click  on eac...
Geo technical Geotech. Soil Mechanics : Download above File and Click on eac...Make Mannan
 
Slabs Beam Reinforcement Detailing
Slabs Beam Reinforcement DetailingSlabs Beam Reinforcement Detailing
Slabs Beam Reinforcement DetailingMake Mannan
 
Thanks vote english
Thanks vote englishThanks vote english
Thanks vote englishMake Mannan
 
Bricks (usefulsearchorg) (useful search)
Bricks (usefulsearchorg) (useful search)Bricks (usefulsearchorg) (useful search)
Bricks (usefulsearchorg) (useful search)Make Mannan
 
Be 205 basic civil engineering jun 09 (useful search)
Be 205 basic civil engineering jun 09 (useful search)Be 205 basic civil engineering jun 09 (useful search)
Be 205 basic civil engineering jun 09 (useful search)Make Mannan
 
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)Make Mannan
 
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)Make Mannan
 
Be 204 basic civil engineering and engineering mechanics dec 14 (useful search)
Be 204 basic civil engineering and engineering mechanics dec 14  (useful search)Be 204 basic civil engineering and engineering mechanics dec 14  (useful search)
Be 204 basic civil engineering and engineering mechanics dec 14 (useful search)Make Mannan
 
Be 204 basic civil engineering and engineering mechanics dec 13 (useful search)
Be 204 basic civil engineering and engineering mechanics dec 13  (useful search)Be 204 basic civil engineering and engineering mechanics dec 13  (useful search)
Be 204 basic civil engineering and engineering mechanics dec 13 (useful search)Make Mannan
 
Sheet pile (usefulsearch.org) (useful search)
Sheet pile (usefulsearch.org) (useful search)Sheet pile (usefulsearch.org) (useful search)
Sheet pile (usefulsearch.org) (useful search)Make Mannan
 
Sheet pile and bulkhead (usefulsearch.org) (useful search)
Sheet pile and bulkhead (usefulsearch.org)  (useful search)Sheet pile and bulkhead (usefulsearch.org)  (useful search)
Sheet pile and bulkhead (usefulsearch.org) (useful search)Make Mannan
 
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...Soil exploration/Investigation method, purpose depth of exploration (Usefulse...
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...Make Mannan
 
Under reamed pile construction (usefulsearch.org) (useful search)
Under reamed pile construction (usefulsearch.org)  (useful search)Under reamed pile construction (usefulsearch.org)  (useful search)
Under reamed pile construction (usefulsearch.org) (useful search)Make Mannan
 
Pile dynamic capacity formula (usefulsearch.org) (useful search)
Pile dynamic capacity formula (usefulsearch.org)  (useful search)Pile dynamic capacity formula (usefulsearch.org)  (useful search)
Pile dynamic capacity formula (usefulsearch.org) (useful search)Make Mannan
 
Static pile capacity formula (usefulsearch.org) (useful search)
Static pile capacity formula (usefulsearch.org)  (useful search)Static pile capacity formula (usefulsearch.org)  (useful search)
Static pile capacity formula (usefulsearch.org) (useful search)Make Mannan
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...Make Mannan
 

More from Make Mannan (20)

Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
Earth quake failures best
Earth quake failures bestEarth quake failures best
Earth quake failures best
 
Engineering Graphics Drawing PPT : Download above File and Click on each topi...
Engineering Graphics Drawing PPT : Download above File and Click on each topi...Engineering Graphics Drawing PPT : Download above File and Click on each topi...
Engineering Graphics Drawing PPT : Download above File and Click on each topi...
 
Geo technical Geotech. Soil Mechanics : Download above File and Click on eac...
Geo technical Geotech. Soil Mechanics : Download above File and Click  on eac...Geo technical Geotech. Soil Mechanics : Download above File and Click  on eac...
Geo technical Geotech. Soil Mechanics : Download above File and Click on eac...
 
Slabs Beam Reinforcement Detailing
Slabs Beam Reinforcement DetailingSlabs Beam Reinforcement Detailing
Slabs Beam Reinforcement Detailing
 
Thanks vote english
Thanks vote englishThanks vote english
Thanks vote english
 
Bricks (usefulsearchorg) (useful search)
Bricks (usefulsearchorg) (useful search)Bricks (usefulsearchorg) (useful search)
Bricks (usefulsearchorg) (useful search)
 
Basic paper
Basic paperBasic paper
Basic paper
 
Be 205 basic civil engineering jun 09 (useful search)
Be 205 basic civil engineering jun 09 (useful search)Be 205 basic civil engineering jun 09 (useful search)
Be 205 basic civil engineering jun 09 (useful search)
 
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 14 (useful search)
 
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)
Be 204 basic civil engineering and engineering mechanics jun 13 (useful search)
 
Be 204 basic civil engineering and engineering mechanics dec 14 (useful search)
Be 204 basic civil engineering and engineering mechanics dec 14  (useful search)Be 204 basic civil engineering and engineering mechanics dec 14  (useful search)
Be 204 basic civil engineering and engineering mechanics dec 14 (useful search)
 
Be 204 basic civil engineering and engineering mechanics dec 13 (useful search)
Be 204 basic civil engineering and engineering mechanics dec 13  (useful search)Be 204 basic civil engineering and engineering mechanics dec 13  (useful search)
Be 204 basic civil engineering and engineering mechanics dec 13 (useful search)
 
Sheet pile (usefulsearch.org) (useful search)
Sheet pile (usefulsearch.org) (useful search)Sheet pile (usefulsearch.org) (useful search)
Sheet pile (usefulsearch.org) (useful search)
 
Sheet pile and bulkhead (usefulsearch.org) (useful search)
Sheet pile and bulkhead (usefulsearch.org)  (useful search)Sheet pile and bulkhead (usefulsearch.org)  (useful search)
Sheet pile and bulkhead (usefulsearch.org) (useful search)
 
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...Soil exploration/Investigation method, purpose depth of exploration (Usefulse...
Soil exploration/Investigation method, purpose depth of exploration (Usefulse...
 
Under reamed pile construction (usefulsearch.org) (useful search)
Under reamed pile construction (usefulsearch.org)  (useful search)Under reamed pile construction (usefulsearch.org)  (useful search)
Under reamed pile construction (usefulsearch.org) (useful search)
 
Pile dynamic capacity formula (usefulsearch.org) (useful search)
Pile dynamic capacity formula (usefulsearch.org)  (useful search)Pile dynamic capacity formula (usefulsearch.org)  (useful search)
Pile dynamic capacity formula (usefulsearch.org) (useful search)
 
Static pile capacity formula (usefulsearch.org) (useful search)
Static pile capacity formula (usefulsearch.org)  (useful search)Static pile capacity formula (usefulsearch.org)  (useful search)
Static pile capacity formula (usefulsearch.org) (useful search)
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
 

Recently uploaded

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
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
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
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stageAbc194748
 
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
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
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
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
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
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Recently uploaded (20)

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
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
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...
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
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
 
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
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
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
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
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
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)

  • 1. Operating System [CS-502] Lab Manual Session July- 2012 a) FCFS: AIM: A program to simulate the FCFS CPU scheduling algorithm. ALGORITHM: Step 1: Start the program. Step 2: Read the needed variables and the number of process. Step 3: Read the burst time for all process. Step 4: Read the arrival time (AT). Step 5: Calculate the waiting time and turn around time and display it. Step 6: Calculate the average waiting time and average total turnaround time and display it. Step 7: Stop the program. PROGRAM: #include<stdio.h> #include<string.h> #include<conio.h> main() { char pn[10][10],t[10]; int arr[10],bur[10],star[10],finish[10],tat[10],wt[10],i,j,n,temp; int totwt=0,tottat=0; //clrscr(); printf("Enter the number of processes:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter the Process Name, Arrival Time & Burst Time:"); scanf("%s%d%d",&pn[i],&arr[i],&bur[i]); } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(arr[i]<arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; temp=bur[i]; bur[i]=bur[j]; bur[j]=temp; strcpy(t,pn[i]); strcpy(pn[i],pn[j]); strcpy(pn[j],t); } } } for(i=0;i<n;i++) { if(i==0) star[i]=arr[i]; else star[i]=finish[i-1]; wt[i]=star[i]-arr[i]; finish[i]=star[i]+bur[i]; tat[i]=finish[i]-arr[i]; } printf("nPName Arrtime Burtime WaitTime Start TAT Finish");
  • 2. for(i=0;i<n;i++) { printf("n%st%3dt%3dt%3dt%3dt%6dt%6d",pn[i],arr[i],bur[i],wt[i],star[i],tat[i],finish[i]); totwt+=wt[i]; tottat+=tat[i]; } printf("nAverage Waiting time:%f",(float)totwt/n); printf("nAverage Turn Around Time:%f",(float)tottat/n); getch(); return 0; } OUTPUT: Enter the number of processes: 3 Enter the Process Name, Arrival Time & Burst Time: p1 2 4 Enter the Process Name, Arrival Time & Burst Time: p2 3 5 Enter the Process Name, Arrival Time & Burst Time: p3 1 6 PName Arrtime Burtime WaitTime Strart TAT Finish p3 1 6 0 1 6 7 p1 2 4 5 7 9 11 p2 3 5 8 11 13 16 Average Waiting Time: 4.3333333 Average Turn Around Time: 9.33333333 Q.1What is CPU scheduling? Q.2What is turnaround time? Q.3What is waiting time? b) SJF: AIM: A program to simulate the SJF CPU scheduling algorithm ALGORITHM: Step 1: Start the program. Step 2: Declare the variable. Step 3: Read the value of n. Step 4: Scan the value of p[i] for i=1 to i Step 5: Read the value of at and print the value of at. Step 6: Do step 7 for i=1 to i Step 7: Do step 8 for j=j+1 to j<=n and increment j value by 1. Step 8: if p[i]>p[j], then assign t=p[j] and p[j]=p[i],then p[i]=t. Step 9: Assign w[j]=at,at=at+p[i]. Step 10: Print the value at. Step 11: Do step 8 for i=1,i<=n and increment value of i by 1. Step 12: Assign sum=sum+w[i] and print the value of w[i]. Step 13: Assign avg=sum/n then print the value of avg. Step 14: Print the value of i and p[i],w[i]. Step 15: Assign avg1=sum1/n and print the value of avg1.
  • 3. Step 16: Stop the program. PROGRAM: #include<stdio.h> #include<conio.h> #include<string.h> void main() { int et[20],at[10],n,i,j,temp,st[10],ft[10],wt[10],ta[10]; int totwt=0,totta=0; float awt,ata; char pn[10][10],t[10]; clrscr(); printf("Enter the number of process:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter process name, arrival time & execution time:"); flushall(); scanf("%s%d%d",pn[i],&at[i],&et[i]); } for(i=0;i<n;i++) for(j=0;j<n;j++) { if(et[i]<et[j]) { temp=at[i]; at[i]=at[j]; at[j]=temp; temp=et[i]; et[i]=et[j]; et[j]=temp; strcpy(t,pn[i]); strcpy(pn[i],pn[j]); strcpy(pn[j],t); } } for(i=0;i<n;i++) { if(i==0) st[i]=at[i]; else st[i]=ft[i-1]; wt[i]=st[i]-at[i]; ft[i]=st[i]+et[i]; ta[i]=ft[i]-at[i]; totwt+=wt[i]; totta+=ta[i]; } awt=(float)totwt/n; ata=(float)totta/n; printf("nPnametarrivaltimetexecutiontimetwaitingtimettatime"); for(i=0;i<n;i++) printf("n%st%5dtt%5dtt%5dtt%5d",pn[i],at[i],et[i],wt[i],ta[i]); printf("nAverage waiting time is:%f",awt); printf("nAverage turnaroundtime is:%f",ata); getch(); } OUTPUT: Enter the number of processes: 3 Enter the Process Name, Arrival Time & Burst Time: 1 4 6
  • 4. Enter the Process Name, Arrival Time & Burst Time: 2 5 15 Enter the Process Name, Arrival Time & Burst Time: 3 6 11 Pname arrivaltime executiontime waitingtime tatime 1 4 6 0 6 3 6 11 4 15 2 5 15 16 31 Average Waiting Time: 6.6667 Average Turn Around Time: 17.3333 Q.1What is the use of CPU scheduling? Q.2What is burst time? Q.3What is SJF CPU scheduling? c) Priority: AIM: A program to simulate the priority CPU scheduling algorithm ALGORITHM: Step 1: Start the program. Step 2: Declare the variables as required. Step 3: Get the number of process. Step 4: Get the burst time for each process. Step 5: get the ID value for each process. Step 6: Get the arrival time for each process. Step 7: Using the read data find the waiting time and turnaround time and average turn around time and print the result. Step 8: Stop the program. PROGRAM: #include<stdio.h> #include<conio.h> #include<string.h> void main() { int et[20],at[10],n,i,j,temp,p[10],st[10],ft[10],wt[10],ta[10]; int totwt=0,totta=0; float awt,ata; char pn[10][10],t[10]; clrscr(); printf("Enter the number of process:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter process name,arrivaltime,execution time & priority:"); flushall(); scanf("%s%d%d%d",pn[i],&at[i],&et[i],&p[i]); } for(i=0;i<n;i++) for(j=0;j<n;j++) { if(p[i]<p[j]) {
  • 5. temp=p[i]; p[i]=p[j]; p[j]=temp; temp=at[i]; at[i]=at[j]; at[j]=temp; temp=et[i]; et[i]=et[j]; et[j]=temp; strcpy(t,pn[i]); strcpy(pn[i],pn[j]); strcpy(pn[j],t); } } for(i=0;i<n;i++) { if(i==0) { st[i]=at[i]; wt[i]=st[i]-at[i]; ft[i]=st[i]+et[i]; ta[i]=ft[i]-at[i]; } else { st[i]=ft[i-1]; wt[i]=st[i]-at[i]; ft[i]=st[i]+et[i]; ta[i]=ft[i]-at[i]; } totwt+=wt[i]; totta+=ta[i]; } awt=(float)totwt/n; ata=(float)totta/n; printf("nPnametarrivaltimetexecutiontimetprioritytwaitingtimettatime"); for(i=0;i<n;i++) printf("n%st%5dtt%5dtt%5dtt%5dtt%5d",pn[i],at[i],et[i],p[i],wt[i],ta[i]); printf("nAverage waiting time is:%f",awt); printf("nAverage turnaroundtime is:%f",ata); getch(); } OUTPUT: Enter the number of processes: 3 Enter the Process Name, Arrival Time, execution time & priority: 1 2 3 1 Enter the Process Name, Arrival Time, execution time & priority: 2 4 5 2 Enter the Process Name, Arrival Time, execution time & priority: 3 5 6 3 Pname arrivaltime executiontime priority waitingtime tatime 1 2 3 1 0 3 2 4 5 2 1 6 3 5 6 3 5 11 Average Waiting Time: 2.0000 Average Turn Around Time: 6.6667 Q.1What is Priority CPU scheduling? Q.2What is the advantage of Priority CPU scheduling.
  • 6. d) Round Robin: AIM: A program to simulate the Round Robin CPU scheduling algorithm ALGORITHM: Step 1: Start the program. Step 2: Declare the variables as required. Step 3: Get the number of process. Step 4: Get the burst time for each process. Step 5: get the quantum value. Step 6: Get the arrival time for each process. Step 7: Using the read data find the waiting time and turnaround time and average turn around time and print the result. Step 8: Stop the program. PROGRAM: #include<stdio.h> #include<conio.h> void main() { int et[30],ts,n,i,x=0,tot=0; char pn[10][10]; clrscr(); printf("Enter the no of processes:"); scanf("%d",&n); printf("Enter the time quantum:"); scanf("%d",&ts); for(i=0;i<n;i++) { printf("enter process name & estimated time:"); scanf("%s %d",pn[i],&et[i]); } printf("The processes are:"); for(i=0;i<n;i++) printf("process %d: %sn",i+1,pn[i]); for(i=0;i<n;i++) tot=tot+et[i]; while(x!=tot) { for(i=0;i<n;i++) { if(et[i]>ts) { x=x+ts; printf("n %s -> %d",pn[i],ts); et[i]=et[i]-ts; } else if((et[i]<=ts)&&et[i]!=0) { x=x+et[i]; printf("n %s -> %d",pn[i],et[i]); et[i]=0;} } } printf("n Total Estimated Time:%d",x);
  • 7. getch(); } OUTPUT: Enter the no of processes: 2 Enter the time quantum: 3 Enter the process name & estimated time: p1 12 Enter the process name & estimated time: p2 15 p1 -> 3 p2 -> 3 p1 -> 3 p2 -> 3 p1 -> 3 p2 -> 3 p1 -> 3 p2 -> 3 p2 -> 3 Total Estimated Time: 27 Q.1What is Round Robin CPU scheduling? Q.2What is the advantage of Round robin CPU scheduling? 5-AIM:To write a C program for implementing Producer Consumer problem using Semaphore. ALGORITHM: Step 1: Start the program. Step 2: Get the choice 1 for Producer, 2 for Consumer. Step 3: If the choice is 1, the produced buffer size is 1, again if the choice is 1 then buffer size will be increased[produced buffer = 1 + 1 = 2]. Step 4: If the choice is 2, the consumed buffer size is 1. Step 5: Stop the program.
  • 8. PROGRAM: #include<stdio.h> #include<conio.h> #include<stdlib.h> //#include<process.h> #define max 5 int n,produced,consumed,buffer[max]; int result,i; int producer(int consumed,int result) { if((consumed=1)&&(i>=0)) { result=result+1; i++; buffer[i]=result; produced=1; printf("Produced bufffer=%dn",buffer[i]); consumed=0; return(produced,result); } else printf("Buffer still to be consumedn"); } int consumer(int produced,int result) { if((produced==1)&&(i>0)) { consumed=1; printf("Consumed buffer=%dn",buffer[i]); produced=0; i--; return(consumed,result); } else printf("Buffer still to be produced"); } int main() { clrscr(); produced=0; consumed=1; result=0; i=0; while(1) { printf("Enter the choicen"); printf("1.Producer 2.Consumer 3.Exitn"); scanf("%d",&n); if(n==3) exit(0); else if(n==1) producer(consumed,buffer[i]); else if(n==2) consumer(produced,buffer[i]); else exit(0); } } SAMPLE OUTPUT:
  • 9. Enter the choice 1.Producer 2.Consumer 3.Exit 1 Produced Buffer = 1 Enter the choice 1.Producer 2.Consumer 3.Exit 1 Produced Buffer = 2 Enter the choice 1.Producer 2.Consumer 3.Exit 2 Consumed Buffer = 2 Enter the choice 1.Producer 2.Consumer 3.Exit 2 Consumed Buffer = 1 Enter the choice 1.Producer 2.Consumer 3.Exit 2 Buffer still to be produced Enter the choice 1.Producer 2.Consumer 3.Exit 6-aim-wap to implement optimal page replacement algorithm program: #include<stdio.h> #include<conio.h> int fr[3]; void main() { void display(); int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3]; int max,found=0,lg[3],index,k,l,flag1=0,flag2=0,pf=0,frsize=3; clrscr(); for(i=0;i<3;i++) { fr[i]=-1; } for(j=0;j<12;j++) { flag1=0; flag2=0; for(i=0;i<3;i++) { if(fr[i]==p[j]) { flag1=1; flag2=1; break;
  • 11. void display() { int i; printf("n"); for(i=0;i<3;i++) printf("t%d",fr[i]); } output: 2 -1 -1 2 3 -1 2 3 -1 2 3 1 2 3 5 2 3 5 4 3 5 4 3 5 4 3 5 2 3 5 2 3 5 2 3 5 no of page fault:3
  • 12. 7) LRU: AIM: A program to simulate LRU Page Replacement Algorithm PROGRAM: #include<stdio.h> #include<conio.h> void main() { int g=0,a[5],b[20],p=0,q=0,m=0,h,k,i,q1=1,j,u,n; char f='F'; clrscr(); printf("Enter the number of pages:"); scanf("%d",&n); printf("Enter %d Page Numbers:",n); for(i=0;i<n;i++) scanf("%d",&b[i]); for(i=0;i<n;i++) {if(p==0) { if(q>=3) q=0; a[q]=b[i]; q++; if(q1<3) { q1=q; //g=1; } } printf("n%d",b[i]); printf("t"); for(h=0;h<q1;h++) printf("%d",a[h]); if((p==0)&&(q<=3)) { printf("-->%c",f); m++; } p=0; g=0; if(q1==3) { for(k=0;k<q1;k++) { if(b[i+1]==a[k]) p=1; } for(j=0;j<q1;j++) {
  • 13. u=0; k=i; while(k>=(i-1)&&(k>=0)) { if(b[k]==a[j]) u++; k--; } if(u==0) q=j; } } else { for(k=0;k<q;k++) { if(b[i+1]==a[k]) p=1; } } } printf("nNo of faults:%d",m); getch(); } OUTPUT: Enter the Number of Pages: 12 Enter 12 Page Numbers: 2 3 2 1 5 2 4 5 3 2 5 2 2 2-> F 3 23-> F 2 23 1 231-> F 5 251-> F 2 251 4 254-> F 5 254 3 354-> F 2 352-> F 5 352 2 352 No of faults: 7 Q.1-What is demand paging? Q.2- Define LRU? 8) FIFO: AIM: A program to simulate FIFO Page Replacement Algorithm PROGRAM: #include<stdio.h> #include<conio.h> void main() {
  • 14. int a[5],b[20],n,p=0,q=0,m=0,h,k,i,q1=1; char f='F'; clrscr(); printf("Enter the Number of Pages:"); scanf("%d",&n); printf("Enter %d Page Numbers:",n); for(i=0;i<n;i++) scanf("%d",&b[i]); for(i=0;i<n; i++) {if(p==0) { if(q>=3) q=0; a[q]=b[i]; q++; if(q1<3) { q1=q; } } printf("n%d",b[i]); printf("t"); for(h=0;h<q1;h++) printf("%d",a[h]); if((p==0)&&(q<=3)) { printf("-->%c",f); m++; } p=0; for(k=0;k<q1;k++) { if(b[i+1]==a[k]) p=1; } } printf("nNo of faults:%d",m); getch(); } OUTPUT: Enter the Number of Pages: 12 Enter 12 Page Numbers: 2 3 2 1 5 2 4 5 3 2 5 2 2 2-> F 3 23-> F 2 23 1 231-> F 5 531-> F 2 521-> F 4 524-> F 5 524 3 324-> F 2 324 5 354-> F 2 352-> F No of faults: 9 Q.1-What is the use of page replacement algorithm? Q.2- What is page fault?
  • 15. Q.3- Define FIFO page replacement algorithm? Q.4- What is the advantage of FIFO? 9-AIM: A program to simulate Bankers Algorithm PROGRAM: // Bankers Algorithm- Systems Lab - C Program #include<stdio.h> #include<stdlib.h> #define true 1 #define false 0 int m,n,i,j,count=0,process; int max[10][10],alloc[10][10],need[10][10],c[10],avail[10],finish[10]; void readtable(int t[10][10]) { for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&t[i][j]); } void printtable(int t[10][10]) { for(i=0;i<m;i++) { for(j=0;j<n;j++) printf("t%d",t[i][j]);
  • 16. printf("n"); } } void readvector(int v[10]) { for(j=0;j<n;j++) scanf("%d",&v[j]); } void printvector(int v[10]) { for(j=0;j<n;j++) printf("t%d",v[j]); } void init() { printf("enter the number of processn"); scanf("%d",&m); printf("enter the number of resourcesn"); scanf("%d",&n); printf("enter the claim tablen"); readtable(max); printf("enter the allocation tablen"); readtable(alloc); printf("enter the max units of each resourcen"); readvector(c); for(i=0;i<n;i++) finish[i]=false; } void findavail() { int sum; for(j=0;j<n;j++) { sum=0; for(i=0;i<m;i++) { sum=sum+alloc[i][j]; } avail[j]=c[j]-sum; } } void findneed() { for(i=0;i<m;i++) { for(j=0;j<n;j++) { need[i][j]=max[i][j]-alloc[i][j]; } } } void selectprocess() { int flag; for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(need[i][j]<=avail[j]) flag=1;
  • 17. else { flag=0; break; } } if((flag==1)&&(finish[i]==false)) { process=i; count++; break; } } printf("current status isn"); printtable(alloc); if(flag==0) { printf("system is in unsafe staten"); exit(1); } printf("system is in safe state"); } void executeprocess(int p) { printf("excuting process is %d",p); printtable(alloc); } void releaseresource() { for(j=0;j<n;j++) avail[j]=avail[j]+alloc[process][j]; for(j=0;j<n;j++) { alloc[process][j]=0; need[process][j]=0; } } Void main() { init(); findavail(); findneed(); do { selectprocess(); finish[process]=true; executeprocess(process); releaseresource(); }while(count<m); printf("n all proces executed correctly"); } OUTPUT: enter the number of process 3 enter the number of resources 2 enter the claim table 0 0 1 1 1 0
  • 18. enter the allocation table 1 1 0 1 1 0 enter the max units of each resource 2 2 current status is 1 1 0 1 1 0 system is in safe state excuting process is 0 1 1 0 1 1 0 current status is 0 0 0 1 1 0 system is in safe state excuting process is 1 0 0 0 1 1 0 current status is 0 0 0 0 1 0 system is in safe state excuting process is 2 0 0 0 0 1 0 all process executed correctly Q.1- Explain Bankers algorithm Q.2- What is deadlock. Q.3- State the necessary condition for deadlock avoidance.