Skip to main content

Posts

Showing posts from November, 2016

Dead Lock Prevention

Bankers algorithm -Deadlock prevention #include<stdio.h> #include<conio.h> int main() { int m,p,s,p1; int m1[4],i,f,f1=0,f2=0,fra1,fra2,s1,pos; clrscr(); printf("Enter the memory size:"); scanf("%d",&m); printf("Enter the no of partitions:"); scanf("%d",&p); s=m/p; printf("Each partn size is:%d",s); printf("\nEnter the no of processes:"); scanf("%d",&p1); pos=m; for(i=0;i<p1;i++) { if(pos<s) { printf("\nThere is no further memory for process%d",i+1); m1[i]=0; break; } else { printf("\nEnter the memory req for process%d:",i+1); scanf("%d",&m1[i]); if(m1[i]<=s) { printf("\nProcess is allocated in partition%d",i+1); fra1=s-m1[i]; printf("\nInternal fragmentation for process is:%d",fra1); f1=f1+fra1; pos=pos-s; } else { printf("\nProcess not allocated in partition%d",i+1); s1=m1[i]; ...

MFT and MVT

MFT Multiprogramming with finite no of tasks #include<stdio.h> #include<conio.h> main() {  int ms, bs, nob, ef,n, mp[10],tif=0;  int i,p=0;  clrscr();  printf("Enter the total memory available (in Bytes) -- ");  scanf("%d",&ms);  printf("Enter the block size (in Bytes) -- ");  scanf("%d", &bs);  nob=ms/bs;  ef=ms - nob*bs;  printf("\nEnter the number of processes -- ");  scanf("%d",&n);  for(i=0;i<n;i++)  { printf("Enter memory required for process %d (in Bytes)-- ",i+1); scanf("%d",&mp[i]);  }  printf("\nNo. of Blocks available in memory -- %d",nob);  printf("\n\nPROCESS\tMEMORY REQUIRED\t ALLOCATED\tINTERNAL FRAGMENTATION");  for(i=0;i<n && p<nob;i++)  { printf("\n %d\t\t%d",i+1,mp[i]); if(mp[i] > bs) printf("\t\tNO\t\t---"); else { printf("\t\tYES\t%d",bs-mp[i]); tif = tif + ...