Clock paging replacement algorithm

2.5k Views Asked by At

Clock replacement algorithm . arr - is physical memory arr2 - pages (virtual memory) if arr haven't page , then replace frame which have R=0 ; If all frames have R=1; Initialize all R=0; IF frame have page and R=1 . Do nothing . Else R=1;

#include<iostream>
using namespace std;
struct Frame
{
    char content;
    int R;
};
int main()
{
    int arr2[] = { 1, 2, 3, 4, 1, 2, 5, 6 };

    Frame arr[3];
    arr[0].R = 1;
    arr[0].content = arr2[0];
    arr[1].R = 1;
    arr[1].content = arr2[1];
    arr[2].R = 1;
    arr[2].content = arr2[2];
    arr[3].R = 1;
    arr[3].content = arr2[3];

    for (int i = 0; i < 3; i++)
    {
        for (int j = 4; j < 8; j++)
        {
            if ((arr[i].content == arr2[j]) && (arr[i].R = 1))
            {
                cout << "Frame have this page";
            }
            else if ((arr[i].content == arr2[j]) && (arr[i].R = 0))
            {
                arr[i].R = 1;
            }
            else if ((arr[i].content != arr2[j]) && (arr[i].R = 1))
            {
                arr[i].R = 0;
            }
            else 
            {
                arr[i].content = arr2[j];
                arr[i].R = 1;
            }
        }
    }

    for (int i = 0; i < 3; i++)
    {
        cout << arr[i].content << " " << arr[i].R << endl;
    }


    system("pause");
    return 0;
}

Error 1 error LNK1168: cannot open C:\Users\h\Documents\Visual Studio 2013\Projects\os clock\Debug\os clock.exe for writing C:\Users\h\Documents\Visual Studio 2013\Projects\os clock\os clock\LINK os clock

1

There are 1 best solutions below

0
On

This error means program is running and you again command compiler to run program although exe file is remain open. first close exe file than run program eliminate this error.