운영체제 실험 - 페이지 주소 재지정
1701 단어 운영 체제 실습 과목
#include
#include
#define PagetableLength 64
using namespace std;
int PageTable[PagetableLength] = {0};
// : 0
int main()
{
int LogicalAddress = 0;
int PageNum = 0;
int w = 0;
int i = 0;
int num = 0;
int f;
int PageSize;
char flag;
cout << " ;" << endl;
cin >> num;
cout << " :" << endl;
cin >> PageSize;
cout << " ;" << endl;
for(i = 0; i < num; i++ )
{
cin >> PageTable[i];
}
cout << " ;
";
for (i = 0; i < num; i++)
{
cout << setw(2) << i << "-->" << setw(2) << PageTable[i];
if(i % 8 == 7)
cout << endl;
}
while(f)
{
cout << endl << " ;
";
cin >> LogicalAddress;
PageNum = LogicalAddress / PageSize;
w = LogicalAddress % PageSize;//
if(PageNum >= PagetableLength)//
{
cout << " , !;
";
return -1;
}
cout << " ;" << endl << PageTable[PageNum] * PageSize + w << endl;
cout << " ? Y/y, " << endl;
cin >> flag;
if(flag == 'Y' || flag == 'y')
f = 1;
else
break;
}
return 0;
}