CS250 – FINAL QUESTIOS AND ANSWERS
Assuming a 32 bit architecture and a 4KB page size, how many first level page tables
are needed for a single process? How many second-level page tables are needed for a
single process? - Answer -One first-level page table is needed. Up to 2^10-1 second-
level page tables are allocated as needed.
Enumerate the page bits in the page table and what each of them is used for. - Answer
-Resident Bit: page is resident in RAM instead of swap space/file
Modified Bit: page has been modified since the last time the bit was cleared. Set by the
MMU
Access Bit: page has been read since the last time the bit was cleared. Set by the MMU
Permission:
Read --> page is readable
Write --> page is writable
Execute --> page can be executed (MMU enforces permissions)
Enumerate the five uses of virtual memory used to speed up the execution of a
program. - Answer -1. Mmap the text segment of an executable or shared library
2. Mmap the data segment of a program
3. Use of VM during fork to copy memory of the parent into the child
4. Allocate zero-initialized memory. It is used to allocate space for bss, stack and sbrk()
5. Shared memory between processes
Explain how copy-on-write works during fork(). - Answer -- After forking the child gets a
copy of the memory of the parent
- Both parent and child share the same physical memory as long as they are not
modified
- When a page is modified by either parent or child, the OS will create a copy of the
page in RAM and will do modifications on the copy
- The copy on write in fork is accomplished by making the common pages read-only
- The OS will catch the modifications during the page-fault, and it will create a copy and
update the page table of the writing process
- Then it will retry the modify instruction
Explain how allocating memory initialized with zeros is accelerated by using Virtual
Memory. - Answer -When a page is modified the OS creates a copy of the page (copy
on write) and retries the modifying instruction. This allows fast allocation. No RAM is
initialized to 0's until the page is modified. This also saves RAM. Only modified pages
use RAM.
Explain what is L1, L2, L3 cache. - Answer -Level 1 cache (L1 cache) - on the
processor chip
Assuming a 32 bit architecture and a 4KB page size, how many first level page tables
are needed for a single process? How many second-level page tables are needed for a
single process? - Answer -One first-level page table is needed. Up to 2^10-1 second-
level page tables are allocated as needed.
Enumerate the page bits in the page table and what each of them is used for. - Answer
-Resident Bit: page is resident in RAM instead of swap space/file
Modified Bit: page has been modified since the last time the bit was cleared. Set by the
MMU
Access Bit: page has been read since the last time the bit was cleared. Set by the MMU
Permission:
Read --> page is readable
Write --> page is writable
Execute --> page can be executed (MMU enforces permissions)
Enumerate the five uses of virtual memory used to speed up the execution of a
program. - Answer -1. Mmap the text segment of an executable or shared library
2. Mmap the data segment of a program
3. Use of VM during fork to copy memory of the parent into the child
4. Allocate zero-initialized memory. It is used to allocate space for bss, stack and sbrk()
5. Shared memory between processes
Explain how copy-on-write works during fork(). - Answer -- After forking the child gets a
copy of the memory of the parent
- Both parent and child share the same physical memory as long as they are not
modified
- When a page is modified by either parent or child, the OS will create a copy of the
page in RAM and will do modifications on the copy
- The copy on write in fork is accomplished by making the common pages read-only
- The OS will catch the modifications during the page-fault, and it will create a copy and
update the page table of the writing process
- Then it will retry the modify instruction
Explain how allocating memory initialized with zeros is accelerated by using Virtual
Memory. - Answer -When a page is modified the OS creates a copy of the page (copy
on write) and retries the modifying instruction. This allows fast allocation. No RAM is
initialized to 0's until the page is modified. This also saves RAM. Only modified pages
use RAM.
Explain what is L1, L2, L3 cache. - Answer -Level 1 cache (L1 cache) - on the
processor chip