Home > C++, Sistem Operasi > Source Code Sistem Paging FIFO Dalam C++

Source Code Sistem Paging FIFO Dalam C++

Source code dibawah menerapkan konsep sistem paging FIFO (First In First Out) dengan menggunakan C++.

 #include "stdio.h"
 #include "stdlib.h"
 #include "iostream.h"
 #include "conio.h"

 int b[4]={0};
 int a[100];
 int m=0,n=0;
 int i,j,x;

 Cetak()
 {
	  int i;
	  printf("  %d   |    Yes     |  ",a[j]);
	  for(i=0;i<4;i++)
	  printf("%d ",b[i]);
	  printf("\n");
	  return 0;
 }

 FIFO()
 {
	  printf("-----------------------------\n");
	  printf("------- Paging  FIFO --------\n");
	  printf("-----------------------------\n");
	  printf(" Page | Page Fault |   Hasil \n");
	  printf("-----------------------------\n");
	  for(j=0;j<4;j++)
	  {
			b[j]=a[j];
			Cetak();
			n++;
			getch();
	  }

	  for(j=4;j<x;j++)
	 {
			m=0;
			for(i=0;i<4;i++)
				 if(a[j]==b[i])
				 {
					  m=1;
					  printf("  %d   |    No      |  Sama \n",a[j]);
					  getch();
					  break;
				 }
			if(m==0)
			{
				 for(i=0;i<3;i++)
				 b[i]=b[i+1];
				 b[3]=a[j];
				 Cetak();
				 n++;
				 getch();
			}
	 }
 printf("-----------------------------\n");
 printf("FIFO page faults : %d\n",n);
 printf("Rata-rata page faults : %f\n",(double)n/x);
 printf("-----------------------------\n");
 getch();
 return 0;
 }

 main()
 {
	  printf("Input Page = ");scanf("%d", &x);

	  for(i=0;i<x;i++)
	  {
	  printf("Page ke - %d = ",i+1);scanf("%d", &a[i]);
	  }
	  printf("\n");
	  printf("Page Number : ");
	  for (i=0;i<x;i++)
	  { printf("%d ",a[i]);
	  }
	  printf("\n \n");
	  FIFO();
	  getch();
	  return 0;
 }

Output program :

sistem paging fifo

>> Download Source Code <<

  1. January 11, 2012 at 2:13 pm

    gan kalo program LIFO ada gak?

    • January 11, 2012 at 2:27 pm

      ga ada..

      ________________________________

  2. Rani
    June 21, 2012 at 6:02 pm

    maaf nih, pas di-run kok output pagingnya cuma sampai page 2? kenapa ya? terimakasih ^^

  3. Rani
    June 21, 2012 at 6:15 pm

    eh tidak jadi. sudah bisa ^^

  4. Afiz Fauzi
    June 23, 2012 at 12:47 pm

    Assalamualaikum..
    maaf gan, kalo paging yang pake metode OPR nya gimana?

  1. June 2, 2010 at 3:03 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: