• 大小: 0.04M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-22
  • 语言: 其他
  • 标签: 其他  

资源简介

.C.rar

资源截图

代码片段和文件信息

#include 
#include 
#define mSIZE 3
#define pSIZE 20
static int memery[mSIZE]={000};
static int process[pSIZE]={70120304230321201701};
void FIFO();
void LRU();
void OPT();

int main()
{
    int codepassword;
    get();
         do
         {
         printf(“enter password:“);
         scanf(“%d“&password);
         }while(password!=722);
      do{

         printf(“---------------------------------------------------\n“);
         printf(“|                       *       *      *********  |\n“);
         printf(“| 1.FIFO                *       *      *   *   *  |\n“);
         printf(“|                  *******************  *******   |\n“);
         printf(“| 2.LRU               * * *   * * *      *        |\n“);
         printf(“|                    *  *  * *  *  *    *  *      |\n“);
         printf(“| 3.OPT             *   *   *   *   *   *******   |\n“);
         printf(“|                  *    *  * *  *    *     *      |\n“);
         printf(“| 4.EXIT          *     * *   * *     **********  |\n“);
         printf(“-------------------------------------------*-------\n“);
         printf(“enter your choice:“);
         scanf(“%d“&code);
         switch(code)
            {
            case 1:{
                     FIFO();
                   }break;
            case 2:{
                     LRU();
                   }break;
            case 3:{
                     OPT();
                   }break;
            case 4:{}break;
            }
         }while (code!=4);
    system(“PAUSE“);
    return 0;
}
get()
    {
    int in;
    for(i=0;i<20;i++)
        {
        printf(“%d “process[i]);
        }
    printf(“\n“);
    }
void FIFO()
{
     int memery[mSIZE]={000};
     int time[mSIZE]={000};
     int ijk;
     int max=0;
     int count=0;
     get();
    for(i=0;i        {
        memery[i]=process[i];
        time[i]=i;
            for(j=0;j               {
                printf(“%d “memery[j]);
                }
        printf(“\n“);
        }      /*前mSIZE个数直接放入*/
    for(i=mSIZE;i    {
        for(j=0k=0;j            {
             if(memery[j]!=process[i])
                  k++;
            }/*判断新页面号是否在物理块中*/
        if(k==mSIZE)/*如果都不在物理块中*/
            {
            count++;
             if(time[0]                max=0;
               else max=1;
             if(time[2]                max=2;
            memery[max]=process[i];
            time[max]=i;
            for(j=0;j                {
                 printf(“%d “memery[j]);
                }
            printf(“\n“);
            }
        else
            {
            for(j=0;j                {
                 printf(“%d “memery[j]);
                }
            printf(“\n“);
            }

    }
     printf(“time:%d\n“co

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6387  2009-01-04 08:58  页面置换算法.C.c

     文件     131072  2009-01-04 10:22  页面置换实验报告.doc

----------- ---------  ---------- -----  ----

               137459                    2


评论

共有 条评论