Search
 
SCRIPT & CODE EXAMPLE
 

C

fifo page algorithm in C

#include <stdio.h>
int main()
{
int referenceString[10], pageFaults = 0, m, n, s, pages, frames;
printf("
Enter the number of Pages:	");
scanf("%d", &pages);
printf("
Enter reference string values:
");
for( m = 0; m < pages; m++)
{
   printf("Value No. [%d]:	", m + 1);
   scanf("%d", &referenceString[m]);
}
printf("
 What are the total number of frames:	");
{
   scanf("%d", &frames);
}
int temp[frames];
for(m = 0; m < frames; m++)
{
  temp[m] = -1;
}
for(m = 0; m < pages; m++)
{
  s = 0;
  for(n = 0; n < frames; n++)
   {
      if(referenceString[m] == temp[n])
         {
            s++;
            pageFaults--;
         }
   }     
   pageFaults++;
   if((pageFaults <= frames) && (s == 0))
      {
        temp[m] = referenceString[m];
      }   
   else if(s == 0)
      {
        temp[(pageFaults - 1) % frames] = referenceString[m];
      }
      printf("
");
      for(n = 0; n < frames; n++)
       {     
         printf("%d	", temp[n]);
       }
} 
printf("
Total Page Faults:	%d
", pageFaults);
return 0;
}
Comment

fifo page algorithm in C

#include <stdio.h>
int main()
{
int referenceString[10], pageFaults = 0, m, n, s, pages, frames;
printf("
Enter the number of Pages:	");
scanf("%d", &pages);
printf("
Enter reference string values:
");
for( m = 0; m < pages; m++)
{
   printf("Value No. [%d]:	", m + 1);
   scanf("%d", &referenceString[m]);
}
printf("
 What are the total number of frames:	");
{
   scanf("%d", &frames);
}
int temp[frames];
for(m = 0; m < frames; m++)
{
  temp[m] = -1;
}
for(m = 0; m < pages; m++)
{
  s = 0;
  for(n = 0; n < frames; n++)
   {
      if(referenceString[m] == temp[n])
         {
            s++;
            pageFaults--;
         }
   }     
   pageFaults++;
   if((pageFaults <= frames) && (s == 0))
      {
        temp[m] = referenceString[m];
      }   
   else if(s == 0)
      {
        temp[(pageFaults - 1) % frames] = referenceString[m];
      }
      printf("
");
      for(n = 0; n < frames; n++)
       {     
         printf("%d	", temp[n]);
       }
} 
printf("
Total Page Faults:	%d
", pageFaults);
return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: obstacle avoiding robot in c++ program 
C :: Command to compile and execute a c file program consecutively 
C :: le reste de division in algorithm c 
C :: c to c convertor 
C :: convert c to phyton 
C :: como somar em C 
C :: print in c 11111 00000 11111 00000 11111 
C :: c program for fibonacci series 
C :: c to assembly online compiler 
C :: best graphic video template for editing free download 
C :: uninstall elgg from hostgtor 
C :: ejemplo c holamundo 
C :: error: ‘_Atomic’ does not name a type 
C :: input multipal data types 
C :: condition ternaire in c 
C :: Entering raw mode 
C :: gnuplot rectangle border color 
C :: how to import c data type 
C :: C program determines the height status for heights in cm 
C :: libraries that are not supported by null sound safety in flutter 
C :: why return 0 is written at the code end? 
C :: how to use arry 
C :: snprintf with malloc 
C :: transpose of a matrix in c 
C :: i2c scanner 
C :: visual studio code 
Dart :: text overflow ellipsis flutter 
Dart :: sleep in dart 
Dart :: flutter appbar icon 
Dart :: put container in bottom column flutter 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =