1.) Consider a computer system that uses demand paging. The size of each page is
ID: 3693682 • Letter: 1
Question
1.) Consider a computer system that uses demand paging. The size of each page is 128 words. A two dimensional array data[128][128] of words is stored row major, that is, the array is stored as follows: data[0][0], data[0][1], ..., data[0][127], data[1][0], data [1][1], ..., data[127][127].
For the following code fragments (that initialize the array), state the number of page faults assuming that 8 pages are allocated to the process and FIFO is used as the page replacement algorithm. Explain your answer.
a) for (j = 0; j <128; j++)
for (i = 0; i < 128; i++)
data[i,j] = 0;
b) for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;
2.) Consider a computer system with a 64-bit logical address and 4-KB page size. The system supports up to 1GB (2^30 bytes) of physical memory. How many entries are there in a single-level page table?
3.) Consider a file system on a disk with disk block size of 256 bytes.
Assume that the file allocation information ([start, end] or index block) is already in memory. For each of the three allocation strategies (contiguous, linked, and indexed with a single index block already in memory), answer the following question: If we are currently at logical block 12 (the last block accessed was block 12) and want to access logical block 6, how many physical blocks must be read from the disk? Note: Logical block numbers start at 0.
4.) If the block size of a Unix file system is 1KB and the disk address length (length of the pointer to a disk block) is 4 bytes, what is the maximum file size if the file control block of a file contains 16 direct entries, one single indirect entry, and one double indirect entry?
Explanation / Answer
Answer:
a)
for (j = 0; j <128; j++)
for (i = 0; i < 128; i++)
data[i,j] = 0;
The array is stored in row major form, that is, the array is stored as data[0][0], data[0][1], ···, data[0][127], data[1][0], data[1][1], ···, data[127][127].
It is given that size of each page is 128 words.So,for pages of 128 words, each row takes one page. so code will causes page fault for each A[i][j] access so total number of page faults = 128 × 128 = 16,384 page faults.
(b)
for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;
In this code zero is assigned to all the words on one page before starting the next page, so it reduces the number of page faults to 128.
The array is stored in row major form, that is, the array is stored as data[0][0], data[0][1], ···, data[0][127], data[1][0], data[1][1], ···, data[127][127].
It is given that size of each page is 128 words.So,for pages of 128 words, each row takes one page. so code will causes page fault for each A[i][j] access so total number of page faults = 128 × 128 = 16,384 page faults.
(b)
for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;
In this code zero is assigned to all the words on one page before starting the next page, so it reduces the number of page faults to 128.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.