Posts

Showing posts from February, 2018

To implement Deadlock Avoidance Using Bankers Algorithm In C Programming

//Deadlock   Avoidance Using Bankers Algorithm In C Programming #include<stdio.h> void main() {   int allocated[15][15],max[15][15],need[15][15],avail[15],tres[15],work[15],flag[15];   int pno,rno,i,j,prc,count,t,total;   count=0;   printf("\n Enter number of process:");   scanf("%d",&pno);   printf("\n Enter number of resources:");   scanf("%d",&rno);   for(i=1;i<=pno;i++)   {   flag[i]=0;   }   printf("\n Enter total numbers of each resources:");   for(i=1;i<= rno;i++)   scanf("%d",&tres[i]);   printf("\n Enter Max resources for each process:");   for(i=1;i<= pno;i++)   {   printf("\n for process %d:",i);   for(j=1;j<= rno;j++)    scanf("%d",&max[i][j]);   }   printf("\n Enter allocated resources for each process:");   for(i=1;i<= pno;i++)   {   printf("\n for process %d:",i);

Write a C Program To Implement LRU Page Replacement Algorithm in operating system

#include<stdio.h> int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1; int recent[10],lrucal[50],count=0; int lruvictim(); void main() { printf("\n\t\t\t LRU PAGE REPLACEMENT ALGORITHM"); printf("\n Enter no.of Frames...."); scanf("%d",&nof); printf(" Enter no.of reference string.."); scanf("%d",&nor); printf("\n Enter reference string.."); for(i=0;i<nor;i++) scanf("%d",&ref[i]); printf("\n\n\t\t LRU PAGE REPLACEMENT ALGORITHM "); printf("\n\t The given reference string:"); printf("\n……………………………….."); for(i=0;i<nor;i++) printf("%4d",ref[i]); for(i=1;i<=nof;i++) { frm[i]=-1; lrucal[i]=0; } for(i=0;i<10;i++) recent[i]=0; printf("\n"); for(i=0;i<nor;i++) { flag=0; printf("\n\t Reference NO %d->\t",ref[i]); for(j=0;j<nof;j++) { if(frm[j]==ref[i]) { flag=1; break; } } if(flag==0)

Write a C Program To Implement optimal Page Replacement Algorithm in operating system

#include<stdio.h> int n,page[20],f,fr[20],i; void display() {  for(i=0;i<f;i++)  {   printf("%8d",fr[i]);  }  printf("\n"); } void request() {  printf("enter no.of pages:");  scanf("%d",&n);  printf("enter no.of frames:");  scanf("%d",&f);  printf("enter no.of page no.s");  for(i=0;i<n;i++)  {   scanf("%d",&page[i]);  }  for(i=0;i<n;i++)  {   fr[i]=-1;  } } void replace() {  int j,flag=0,pf=0;  int max,lp[10],index,m;  for(j=0;j<f;j++)  {   fr[j]=page[j];   flag=1;   pf++;   display();  }  for(j=f;j<n;j++)  {   flag=0;   for(i=0;i<f;i++)   {    if(fr[i]==page[j])    {     flag=1;     break;    }   }   if(flag==0)   {    for(i=0;i<f;i++)    lp[i]=0;    for(i=0;i<f;i++)    {     for(m=j+1;m<n;m++)     {      if(fr[i]==page[m])      {       lp[i]=m-j;       break;      }     }    }    max=lp[0];    in

Write a C Program To Implement FIFO Page Replacement Algorithm in operating system

#include<stdio.h> int i,j,nof,nors,flag=0,ref[50],frm[50],pf=0,victim=-1; void main() {       printf("\n \t\t\t FIFI PAGE REPLACEMENT ALGORITHM");       printf("\n Enter no.of frames...."); // Get number of frames from user scanf("%d",&nof); printf("Enter number of reference string..\n"); scanf("%d",&nors); printf("\n Enter the reference string.."); for(i=0;i<nors;i++) scanf("%d",&ref[i]); printf("\nThe given reference string:"); for(i=0;i<nors;i++) printf("%4d",ref[i]); for(i=1;i<=nof;i++) frm[i]=-1; printf("\n"); for(i=0;i<nors;i++) // For every page { flag=0; // Flag to show availability of page in frame // Get the availability of required page in frame printf("\n\t Reference np%d->\t",ref[i]); for(j=0;j<nof;j++) { if(frm[j]==ref[i])   // If page found in frame { flag=1; // Set flag to

Write C programs to simulate the Paging techniques of memory management

Image
#include<stdio.h> #define MAX 50 int main() { int page[MAX],i,n,f,ps,off,pno; int choice=0; printf("\nEnter the no of  peges in memory: "); scanf("%d",&n); printf("\nEnter page size: "); scanf("%d",&ps); printf("\nEnter no of frames: "); scanf("%d",&f); for(i=0;i<n;i++) page[i]=-1; printf("\nEnter the page table\n"); printf("(Enter frame no as -1 if that page is not present in any frame)\n\n"); printf("\npageno\tframeno\n-------\t-------"); for(i=0;i<n;i++) { printf("\n\n%d\t\t",i); scanf("%d",&page[i]); } do { printf("\n\nEnter the logical address(i.e,page no & offset):"); scanf("%d%d",&pno,&off); if(page[pno]==-1) printf("\n\nThe required page is not available in any of frames"); else printf("\n\nPhysical address(i.e,frame no & offset):%d,%d",page[pno],off); prin