GATE 2008
185 questions
MCQ 1851-mark 52 · 2-mark 133
Questions 146–150 of 185
Match the following flag bits used in the context of virtual memory management on the left side with the different purposes on the right side of the table below.
Answer: (D)
Dirty: set when the page is written. The OS checks it to know whether the page must be written back to disk before its frame is reused, so it goes with the write-back policy (I-b).
R/W: if set, the page can be read and written; if clear, it is read-only. It guards the page, so it is page protection (II-c).
Reference: set by the hardware each time the page is accessed, and cleared by the OS from time to time. Replacement methods such as second chance use it to avoid evicting pages in use, so it is the page replacement policy (III-d).
Valid: tells whether the page is in memory. If it is not set, the access traps and the OS has to bring the page in and set it up, which is page initialization (IV-a).
Answer: (D)
R/W: if set, the page can be read and written; if clear, it is read-only. It guards the page, so it is page protection (II-c).
Reference: set by the hardware each time the page is accessed, and cleared by the OS from time to time. Replacement methods such as second chance use it to avoid evicting pages in use, so it is the page replacement policy (III-d).
Valid: tells whether the page is in memory. If it is not set, the access traps and the OS has to bring the page in and set it up, which is page initialization (IV-a).
Answer: (D)
Assume that a main memory with only 4 pages, each of 16 bytes, is initially empty. The CPU generates the following sequence of virtual addresses and uses the Least Recently Used (LRU) page replacement policy.
0, 4, 8, 20, 24, 36, 44, 12, 68, 72, 80, 84, 28, 32, 88, 92
How many page faults does this sequence cause? What are the page numbers of the pages present in the main memory at the end of the sequence?
0, 4, 8, 20, 24, 36, 44, 12, 68, 72, 80, 84, 28, 32, 88, 92
How many page faults does this sequence cause? What are the page numbers of the pages present in the main memory at the end of the sequence?
Answer: (B)
First, we change the given virtual addresses (each one points to a byte) into page addresses (these are also virtual, but each one points to a page). To do this, divide the virtual address by the page size and take the floor value. This is the same as dropping the page offset bits. Here the page size is bytes, so we need offset bits. So,
Memory has spaces for pages. A page is replaced only when a different page arrives. Now let us trace the sequence of memory accesses: So, the answer is choice (B).
A paging scheme uses a Translation Look-aside Buffer (TLB). A TLB-access takes 10 ns and the main memory access takes 50 ns. What is the effective access time(in ns) if the TLB hit ratio is 90% and there is no page-fault?
Answer: (C)
Effective access time hit ratio time on a hit miss ratio time on a miss
The TLB is accessed in both cases. The page table is read from memory only when the TLB misses. This is the assumption.
Putting in the values:
Simplifying:
Correct Answer:
The TLB is accessed in both cases. The page table is read from memory only when the TLB misses. This is the assumption.
Putting in the values:
Simplifying:
Correct Answer:
A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual to physical address translation, where the virtual address is used as follows
Bits 30-31 are used to index into the first level page table
Bits 21-29 are used to index into the second level page table
Bits 12-20 are used to index into the third level page table, and
Bits 0-11 are used as offset within the page
The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page tables are respectively
Bits 30-31 are used to index into the first level page table
Bits 21-29 are used to index into the second level page table
Bits 12-20 are used to index into the third level page table, and
Bits 0-11 are used as offset within the page
The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page tables are respectively
Answer: (D)
Third level (entries point to page frames). The page size is 4 KB, so the offset is 12 bits. A 36-bit physical address leaves bits for the frame number. So each third level entry needs 24 bits.
Second and first level (entries point to the next level page table). Page tables are not assumed to be page-aligned, and tables of different levels can have different sizes. We take each table to start at a multiple of its own size, so the entry must name one of (physical memory size) / (size of one table) possible places.
Third level table: bits 12-20 give entries of 4 bytes, so the table is bytes. Possible third level tables . So each second level entry needs 25 bits.
Second level table: bits 21-29 give entries of 4 bytes, so bytes. Possible second level tables . So each first level entry needs 25 bits.
So the entry sizes are 25, 25 and 24 bits. Option (B) would hold only if every table had to start at a 4 KB page boundary, which the question does not say.
Answer: (D)
Second and first level (entries point to the next level page table). Page tables are not assumed to be page-aligned, and tables of different levels can have different sizes. We take each table to start at a multiple of its own size, so the entry must name one of (physical memory size) / (size of one table) possible places.
Third level table: bits 12-20 give entries of 4 bytes, so the table is bytes. Possible third level tables . So each second level entry needs 25 bits.
Second level table: bits 21-29 give entries of 4 bytes, so bytes. Possible second level tables . So each first level entry needs 25 bits.
So the entry sizes are 25, 25 and 24 bits. Option (B) would hold only if every table had to start at a 4 KB page boundary, which the question does not say.
Answer: (D)
The data blocks of a very large file in the Unix file system are allocated using
Answer: (D)
Contiguous allocation needs one long free run and causes external fragmentation. Linked allocation makes random access slow, since you follow the chain block by block. Plain indexed allocation needs one index block that cannot hold enough pointers for a very large file.
Unix keeps an inode for each file. The inode has some direct pointers to data blocks, then a single indirect pointer (to a block of pointers to data blocks), a double indirect pointer and a triple indirect pointer. So small files use direct pointers and very large files use the multi-level indirect blocks. This is an extension of indexed allocation.
Answer: (D)
Unix keeps an inode for each file. The inode has some direct pointers to data blocks, then a single indirect pointer (to a block of pointers to data blocks), a double indirect pointer and a triple indirect pointer. So small files use direct pointers and very large files use the multi-level indirect blocks. This is an extension of indexed allocation.
Answer: (D)