SlideShare a Scribd company logo
1 of 35
MANAV RACHNA
UNIVERSITY
OS LAB
SAGAR AGGARWAL
B-TECH CSE -4A
2K18CSUN01080
1. To swap two numbers without using a temporary variable.
2. To calculate the bill amount for an item given the quantity sold, rate, discount and tax.
3. Program to enter any character. If the entered character is in lower case then convert it into uppercase and if it is
lower case then convert it into upper case.
4. To enter a character and determine whether it is vowel or not.
5. Program to display a menu that offers five options: Read three numbers, calculate total, average, display the
smallest and largest value.
7. To find the Fibonacci using recursive function.
8. To insert a number at a given location in an array.
10. Accept any two strings from the user. Display whether both the strings are equal or not.(do not use standard
functions).
11. Write a program to accept a list of 10 integers in an array, pass the starting address of array in sum function,
calculate the sum of the array elements in the function and return the sum calculated in the main function.
12. Program to add two numbers using Command Line Arguments
LAB 2-3
Q1
Q2
Q3
LAB 5-7
Q1
FCFS
OUTPUT
Q2 SJF
OUTPUT
Q3 SRTF
OUTPUT
Q4 ROUND ROBIN
OUTPUT
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY
Lab-9
Laboratory Objective: To implement scheduling algorithms in C.
Learning Outcome: Implementation of scheduling algorithms.
1. Implement Priority Scheduling algorithm for three process having the following Burst Time and
Priorities:
Process Burst Time Priority
1 5 2
2 7 1
3 6 3
4 5 4
OUTPUT
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY
Lab-10
Laboratory Objective: To implement scheduling algorithms.
Learning Outcome: Implementation of scheduling algorithms.
2. Implement Producer Consumer Problem using Semaphore:
OUTPUT
OS LAB 11
1- FIRST FIT
#include<stdio.h>
void main()
{
int bsize[10],psize[10],bno, pno,flags[10], allocation[10], i, j;
for(i = 0; i < 10; i++)
{
flags[i]= 0;
allocation[i]= -1;
}
printf("Enterno.of blocks: ");
scanf("%d",&bno);
printf("nEntersize ofeach block: ");
for(i = 0; i < bno; i++)
scanf("%d",&bsize[i]);
printf("nEnterno. ofprocesses:");
scanf("%d",&pno);
printf("nEntersize ofeach process: ");
for(i = 0; i < pno; i++)
scanf("%d",&psize[i]);
for(i = 0; i < pno; i++) //allocation as per first fit
for(j= 0; j < bno; j++)
if(flags[j]== 0 && bsize[j]>= psize[i])
{
allocation[j]= i;
flags[j]= 1;
break;
}
//display allocationdetails
printf("nBlockno.tsizettprocessno.ttsize");
for(i = 0; i < bno; i++)
{
printf("n%dtt%dtt",i+1, bsize[i]);
if(flags[i]== 1)
printf("%dttt%d",allocation[i]+1,psize[allocation[i]]);
else
printf("Notallocated");
}
}
OUTPUT
2- BEST FIT
#include<stdio.h>
void main()
{
int fragment[20],b[20],p[20],i,j,nb,np,temp,lowest=9999;
static int barray[20],parray[20];
printf("ntttMemory Management Scheme - Best Fit");
printf("nEnter the number of blocks:");
scanf("%d",&nb);
printf("Enter the number of processes:");
scanf("%d",&np);
printf("nEnter the size of the blocks:-n");
for(i=1;i<=nb;i++)
{
printf("Block no.%d:",i);
scanf("%d",&b[i]);
}
printf("nEnter the size of the processes :-n");
for(i=1;i<=np;i++)
{
printf("Process no.%d:",i);
scanf("%d",&p[i]);
}
for(i=1;i<=np;i++)
{
for(j=1;j<=nb;j++)
{
if(barray[j]!=1)
{
temp=b[j]-p[i];
if(temp>=0)
if(lowest>temp)
{
parray[i]=j;
lowest=temp;
}
}
}
fragment[i]=lowest;
barray[parray[i]]=1;
lowest=10000;
}
printf("nProcess_notProcess_sizetBlock_notBlock_sizetFragment");
for(i=1;i<=np && parray[i]!=0;i++)
printf("n%dtt%dtt%dtt%dtt%d",i,p[i],parray[i],b[parray[i]],fragment[i]);
}
OUTPUT
3- WORST FIT
#include<stdio.h>
int main()
{
int fragments[10], blocks[10], files[10];
int m, n, number_of_blocks, number_of_files, temp, top = 0;
static int block_arr[10], file_arr[10];
printf("nEnter the Total Number of Blocks:t");
scanf("%d",&number_of_blocks);
printf("Enter the Total Number of Files:t");
scanf("%d",&number_of_files);
printf("nEnter the Size of the Blocks:n");
for(m = 0; m < number_of_blocks; m++)
{
printf("Block No.[%d]:t", m + 1);
scanf("%d", &blocks[m]);
}
printf("Enter the Size of the Files:n");
for(m = 0; m < number_of_files; m++)
{
printf("File No.[%d]:t", m + 1);
scanf("%d", &files[m]);
}
for(m = 0; m < number_of_files; m++)
{
for(n = 0; n < number_of_blocks; n++)
{
if(block_arr[n] != 1)
{
temp = blocks[n] - files[m];
if(temp >= 0)
{
if(top < temp)
{
file_arr[m] = n;
top = temp;
}
}
}
fragments[m] = top;
block_arr[file_arr[m]] = 1;
top = 0;
}
}
printf("nFile NumbertFile SizetBlock NumbertBlock SizetFragment");
for(m = 0; m < number_of_files; m++)
{
printf("n%dtt%dtt%dtt%dtt%d", m, files[m], file_arr[m], blocks[file_arr[m]],
fragments[m]);
}
printf("n");
return 0;
}
OUTPUT
OS LAB 12
OPTIMAL PAGE REPLACEMENT ALGO
#include<stdio.h>
int main()
{
int no_of_frames, no_of_pages, frames[10], pages[30], temp[10], flag1, flag2, flag3, i, j, k,
pos, max, faults = 0;
printf("Enter number of frames: ");
scanf("%d", &no_of_frames);
printf("Enter number of pages: ");
scanf("%d", &no_of_pages);
printf("Enter page reference string: ");
for(i = 0; i < no_of_pages; ++i){
scanf("%d", &pages[i]);
}
for(i = 0; i < no_of_frames; ++i){
frames[i] = -1;
}
for(i = 0; i < no_of_pages; ++i){
flag1 = flag2 = 0;
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == pages[i]){
flag1 = flag2 = 1;
break;
}
}
if(flag1 == 0){
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == -1){
faults++;
frames[j] = pages[i];
flag2 = 1;
break;
}
}
}
if(flag2 == 0){
flag3 =0;
for(j = 0; j < no_of_frames; ++j){
temp[j] = -1;
for(k = i + 1; k < no_of_pages; ++k){
if(frames[j] == pages[k]){
temp[j] = k;
break;
}
}
}
for(j = 0; j < no_of_frames; ++j){
if(temp[j] == -1){
pos = j;
flag3 = 1;
break;
}
}
if(flag3 ==0){
max = temp[0];
pos = 0;
for(j = 1; j < no_of_frames; ++j){
if(temp[j] > max){
max = temp[j];
pos = j;
}
}
}
frames[pos] = pages[i];
faults++;
}
printf("n");
for(j = 0; j < no_of_frames; ++j){
printf("%dt", frames[j]);
}
}
printf("nnTotal Page Faults = %d", faults);
return 0;
}
OUTPUT
LRU PAGE REPLACEMENT ALGORITHM
#include<stdio.h>
int findLRU(int time[], int n){
int i, minimum = time[0], pos = 0;
for(i = 1; i < n; ++i){
if(time[i] < minimum){
minimum = time[i];
pos = i;
}
}
return pos;
}
int main()
{
int no_of_frames, no_of_pages, frames[10], pages[30], counter = 0, time[10], flag1, flag2, i, j,
pos, faults = 0;
printf("Enter number of frames: ");
scanf("%d", &no_of_frames);
printf("Enter number of pages: ");
scanf("%d", &no_of_pages);
printf("Enter reference string: ");
for(i = 0; i < no_of_pages; ++i){
scanf("%d", &pages[i]);
}
for(i = 0; i < no_of_frames; ++i){
frames[i] = -1;
}
for(i = 0; i < no_of_pages; ++i){
flag1 = flag2 = 0;
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == pages[i]){
counter++;
time[j] = counter;
flag1 = flag2 = 1;
break;
}
}
if(flag1 == 0){
for(j = 0; j < no_of_frames; ++j){
if(frames[j] == -1){
counter++;
faults++;
frames[j] = pages[i];
time[j] = counter;
flag2 = 1;
break;
}
}
}
if(flag2 == 0){
pos = findLRU(time, no_of_frames);
counter++;
faults++;
frames[pos] = pages[i];
time[pos] = counter;
}
printf("n");
for(j = 0; j < no_of_frames; ++j){
printf("%dt", frames[j]);
}
}
printf("nnTotal Page Faults = %d", faults);
return 0;
}
OUTPUT
FIFO PAGE REPLACEMENT ALGO
#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;
}
OUTPUT

More Related Content

What's hot

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
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
SPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in CSPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in CMohammad Imam Hossain
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manualSyed Mustafa
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nmmohamed sikander
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File Harjinder Singh
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab filesNitesh Dubey
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rathSANTOSH RATH
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 

What's hot (20)

C program
C programC program
C program
 
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
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
SPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in CSPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in C
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
Pnno
PnnoPnno
Pnno
 
Code optimization
Code optimization Code optimization
Code optimization
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 

Similar to Operating system labs

Similar to Operating system labs (20)

Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
 
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
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
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
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Code optimization
Code optimization Code optimization
Code optimization
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
SPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested LoopSPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested Loop
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
C file
C fileC file
C file
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Array Cont
Array ContArray Cont
Array Cont
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Functions
FunctionsFunctions
Functions
 

Recently uploaded

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Recently uploaded (20)

young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 

Operating system labs

  • 1. MANAV RACHNA UNIVERSITY OS LAB SAGAR AGGARWAL B-TECH CSE -4A 2K18CSUN01080
  • 2. 1. To swap two numbers without using a temporary variable. 2. To calculate the bill amount for an item given the quantity sold, rate, discount and tax.
  • 3. 3. Program to enter any character. If the entered character is in lower case then convert it into uppercase and if it is lower case then convert it into upper case. 4. To enter a character and determine whether it is vowel or not.
  • 4. 5. Program to display a menu that offers five options: Read three numbers, calculate total, average, display the smallest and largest value.
  • 5. 7. To find the Fibonacci using recursive function.
  • 6. 8. To insert a number at a given location in an array. 10. Accept any two strings from the user. Display whether both the strings are equal or not.(do not use standard functions).
  • 7. 11. Write a program to accept a list of 10 integers in an array, pass the starting address of array in sum function, calculate the sum of the array elements in the function and return the sum calculated in the main function.
  • 8. 12. Program to add two numbers using Command Line Arguments LAB 2-3 Q1
  • 14. OUTPUT DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY Lab-9 Laboratory Objective: To implement scheduling algorithms in C. Learning Outcome: Implementation of scheduling algorithms.
  • 15. 1. Implement Priority Scheduling algorithm for three process having the following Burst Time and Priorities: Process Burst Time Priority 1 5 2 2 7 1 3 6 3 4 5 4
  • 17. DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY Lab-10 Laboratory Objective: To implement scheduling algorithms. Learning Outcome: Implementation of scheduling algorithms. 2. Implement Producer Consumer Problem using Semaphore:
  • 18.
  • 20.
  • 21.
  • 22. OS LAB 11 1- FIRST FIT #include<stdio.h> void main() { int bsize[10],psize[10],bno, pno,flags[10], allocation[10], i, j; for(i = 0; i < 10; i++) { flags[i]= 0; allocation[i]= -1; } printf("Enterno.of blocks: "); scanf("%d",&bno); printf("nEntersize ofeach block: "); for(i = 0; i < bno; i++) scanf("%d",&bsize[i]);
  • 23. printf("nEnterno. ofprocesses:"); scanf("%d",&pno); printf("nEntersize ofeach process: "); for(i = 0; i < pno; i++) scanf("%d",&psize[i]); for(i = 0; i < pno; i++) //allocation as per first fit for(j= 0; j < bno; j++) if(flags[j]== 0 && bsize[j]>= psize[i]) { allocation[j]= i; flags[j]= 1; break; } //display allocationdetails printf("nBlockno.tsizettprocessno.ttsize"); for(i = 0; i < bno; i++) { printf("n%dtt%dtt",i+1, bsize[i]); if(flags[i]== 1) printf("%dttt%d",allocation[i]+1,psize[allocation[i]]); else printf("Notallocated"); } }
  • 25. 2- BEST FIT #include<stdio.h> void main() { int fragment[20],b[20],p[20],i,j,nb,np,temp,lowest=9999; static int barray[20],parray[20]; printf("ntttMemory Management Scheme - Best Fit"); printf("nEnter the number of blocks:"); scanf("%d",&nb); printf("Enter the number of processes:"); scanf("%d",&np); printf("nEnter the size of the blocks:-n"); for(i=1;i<=nb;i++) { printf("Block no.%d:",i); scanf("%d",&b[i]); } printf("nEnter the size of the processes :-n"); for(i=1;i<=np;i++) { printf("Process no.%d:",i); scanf("%d",&p[i]); } for(i=1;i<=np;i++) { for(j=1;j<=nb;j++) { if(barray[j]!=1) { temp=b[j]-p[i]; if(temp>=0) if(lowest>temp) { parray[i]=j; lowest=temp;
  • 27. 3- WORST FIT #include<stdio.h> int main() { int fragments[10], blocks[10], files[10]; int m, n, number_of_blocks, number_of_files, temp, top = 0; static int block_arr[10], file_arr[10]; printf("nEnter the Total Number of Blocks:t"); scanf("%d",&number_of_blocks); printf("Enter the Total Number of Files:t"); scanf("%d",&number_of_files); printf("nEnter the Size of the Blocks:n"); for(m = 0; m < number_of_blocks; m++) { printf("Block No.[%d]:t", m + 1); scanf("%d", &blocks[m]); } printf("Enter the Size of the Files:n"); for(m = 0; m < number_of_files; m++) { printf("File No.[%d]:t", m + 1); scanf("%d", &files[m]); } for(m = 0; m < number_of_files; m++) { for(n = 0; n < number_of_blocks; n++) { if(block_arr[n] != 1) { temp = blocks[n] - files[m]; if(temp >= 0) { if(top < temp) { file_arr[m] = n; top = temp; } }
  • 28. } fragments[m] = top; block_arr[file_arr[m]] = 1; top = 0; } } printf("nFile NumbertFile SizetBlock NumbertBlock SizetFragment"); for(m = 0; m < number_of_files; m++) { printf("n%dtt%dtt%dtt%dtt%d", m, files[m], file_arr[m], blocks[file_arr[m]], fragments[m]); } printf("n"); return 0; } OUTPUT
  • 29. OS LAB 12 OPTIMAL PAGE REPLACEMENT ALGO #include<stdio.h> int main() { int no_of_frames, no_of_pages, frames[10], pages[30], temp[10], flag1, flag2, flag3, i, j, k, pos, max, faults = 0; printf("Enter number of frames: "); scanf("%d", &no_of_frames); printf("Enter number of pages: "); scanf("%d", &no_of_pages); printf("Enter page reference string: "); for(i = 0; i < no_of_pages; ++i){ scanf("%d", &pages[i]); } for(i = 0; i < no_of_frames; ++i){ frames[i] = -1; } for(i = 0; i < no_of_pages; ++i){ flag1 = flag2 = 0; for(j = 0; j < no_of_frames; ++j){ if(frames[j] == pages[i]){ flag1 = flag2 = 1; break; } } if(flag1 == 0){ for(j = 0; j < no_of_frames; ++j){ if(frames[j] == -1){ faults++; frames[j] = pages[i]; flag2 = 1; break; } } }
  • 30. if(flag2 == 0){ flag3 =0; for(j = 0; j < no_of_frames; ++j){ temp[j] = -1; for(k = i + 1; k < no_of_pages; ++k){ if(frames[j] == pages[k]){ temp[j] = k; break; } } } for(j = 0; j < no_of_frames; ++j){ if(temp[j] == -1){ pos = j; flag3 = 1; break; } } if(flag3 ==0){ max = temp[0]; pos = 0; for(j = 1; j < no_of_frames; ++j){ if(temp[j] > max){ max = temp[j]; pos = j; } } } frames[pos] = pages[i]; faults++; } printf("n"); for(j = 0; j < no_of_frames; ++j){ printf("%dt", frames[j]); } } printf("nnTotal Page Faults = %d", faults); return 0;
  • 31. } OUTPUT LRU PAGE REPLACEMENT ALGORITHM #include<stdio.h>
  • 32. int findLRU(int time[], int n){ int i, minimum = time[0], pos = 0; for(i = 1; i < n; ++i){ if(time[i] < minimum){ minimum = time[i]; pos = i; } } return pos; } int main() { int no_of_frames, no_of_pages, frames[10], pages[30], counter = 0, time[10], flag1, flag2, i, j, pos, faults = 0; printf("Enter number of frames: "); scanf("%d", &no_of_frames); printf("Enter number of pages: "); scanf("%d", &no_of_pages); printf("Enter reference string: "); for(i = 0; i < no_of_pages; ++i){ scanf("%d", &pages[i]); } for(i = 0; i < no_of_frames; ++i){ frames[i] = -1; } for(i = 0; i < no_of_pages; ++i){ flag1 = flag2 = 0; for(j = 0; j < no_of_frames; ++j){ if(frames[j] == pages[i]){ counter++; time[j] = counter; flag1 = flag2 = 1; break; } } if(flag1 == 0){ for(j = 0; j < no_of_frames; ++j){ if(frames[j] == -1){ counter++; faults++; frames[j] = pages[i];
  • 33. time[j] = counter; flag2 = 1; break; } } } if(flag2 == 0){ pos = findLRU(time, no_of_frames); counter++; faults++; frames[pos] = pages[i]; time[pos] = counter; } printf("n"); for(j = 0; j < no_of_frames; ++j){ printf("%dt", frames[j]); } } printf("nnTotal Page Faults = %d", faults); return 0; } OUTPUT
  • 34. FIFO PAGE REPLACEMENT ALGO #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++;