CS250 Final Exam Homework
a) Solve this homework and turnin your handwritten or printed
answers before the final exam. You will find similar
questions in the final exam. I will post the solutions one day
before the final exam. I strongly suggest you to complete your
homework on your own before looking at the solutions.
b) The final exam will be cumulative but it will concentrate in the
second half of the semester. To prepare for the final review also
the material of the first half of the semester.
1. Assume the virtual address 0x45674237 and a page size of 4KB and
a 32 bit architecture.
a) obtain the page number and the offset.
b) Obtain the first-level index and the second-level index from the
page number assuming that each of them is 10 bits long.
c) Draw a first-level page table and one second-level page table
that will translate the above virtual address to address 0x83467237
2. 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?
3. Enumerate the page bits in the page table and what each of them
is used for.
4. Enumerate the five uses of virtual memory used to speed up the
execution of a program.
5. Explain how copy-on-write works during fork().
6. Explain how allocating memory initiallized with zeros is
accelerated by using Virtual Memory.
7. Explain what is L1, L2, L3 cache.
8. Explain what is locality of reference.
9. Explain in what situations a memory cache will not give good
results.
10. Explain how it is possible in a direct mapping memory cache that
two items that are frequently used cannot be stored in the cache
simultaneously.
11. Explain how buffers are used to reduce the numbers of system
calls and device activity in a computer system.
12. Explain the steps of a interrupt.
13. Explain the steps to process a page fault.
14.In x86-64 Assembly language implement the function int addarray(int n, int * array)
that add all the elements of the array
passed as parameter. n is the length of the array.
15. In x86-64 Assembly language implement a program "maxmin" that
prompts two integer numbers fom stdin and then displays the maximum,
minimum and average of both: numbers. Here is an example of the
usage:
bash> maxmin
a=5
b=8
max=8
min=5
avg=6
16. Write the function strstr(char* haystack, char *needle) in
assembly in x86 language.