이 튜토리얼에서는 운영 체제의 고정 파티션에 대해 알아볼 것입니다.
고정 파티션 운영 체제에서 메모리를 관리하는 것입니다. 오래된 기술입니다. 메모리를 동일한 블록으로 나눕니다. 각 블록의 크기는 미리 정의되어 있으며 변경할 수 없습니다.
메모리는 인접한 프로세스에 사용됩니다.
예시
프로세스 크기에 따라 메모리를 할당하는 샘플 프로그램을 보자.
#include<iostream>
using namespace std;
int main() {
int blockNumber = 5, processesNumber = 3;
int blockSize[5] = {4, 4, 4, 4, 4}, processSize[3] = {1, 2, 3};
int flags[5], allocation[5];
for(int i = 0; i < 5; i++) {
flags[i] = 0;
allocation[i] = -1;
}
// allocating the blocks to processes
for(int i = 0; i < processesNumber; i++) {
for(int j = 0; j < blockNumber; j++) {
if(flags[j] == 0 && blockSize[j] >= processSize[i]) {
allocation[j] = i;
flags[j] = 1;
break;
}
}
}
for (int i = 0; i < blockNumber; i++) {
if (flags[i] == 1) {
cout << "Process " << processSize[allocation[i]] << " is allocated" << endl;
}
}
return 0;
} 출력
위의 프로그램을 실행하면 다음과 같은 결과를 얻을 수 있습니다.
Process 1 is allocated Process 2 is allocated Process 3 is allocated
결론
튜토리얼에서 질문이 있는 경우 댓글 섹션에 언급하세요.