



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1. Walking the X86 Page Tables
In this problem you will write the actual C Code for walking an x86 32-bit page table from the cr3 (PDBR) to the page itself. For this problem you may find it useful to consult the Intel ISA Docs under the tools, references, and links section of the website. Remember that the x86 page tables follow the 10-10-12 format.
You have been tasked with writing the Map Address function. The Map Address function takes in a page ta- ble base address, a physical address and a virtual address. Your task is to create the mapping in the given page table to have the given virtual address point to the given physical address.
You have been provided the following functions:
// Allocates and teturns the address of a new physical page, never fails Unsigned Long Get Page() // takes a pointer and returns an Unsigned Long Page Directory Entry // that points to this address Unsigned Long Make PDE(Unsigned Long (^) * addr) // takes a pointer and returns an Unsigned Long Page Table Entry // that points to this address Unsigned Long Make PTE(Unsigned Long (^) * addr)
You do not need to consider the extra functionality bits in the page table entries other than the present bit. If the Virtual address provided is not in the page tables you must add it into the page tables.
Void Map Address(Unsigned Long PDBR, Unsigned Long Virtual address, Unsigned Long Physical address) {
void rwa write lock(rwasem t* rwa) {
void rwa append lock(rwasem t* rwa) {
void rwa append unlock(rwasem t* rwa) {
The following questions draw upon the ReaderWriterAppender semaphore. In your answers, write no more than a few sentences explaining your reasoning.
Part B: Consider the code below.
Tux() { rwa read lock(&f lock1); rwa write lock(&f lock2); rwa write lock(&f lock3);
/* Function that reads from File1 and writes to Files 2 and 3 (^) */ TuxFoo();
rwa read unlock(&f lock1); rwa write unlock(&f lock2); rwa write unlock(&f lock3); }
Gnu() { rwa read lock(&f lock1); rwa append lock(&f lock3);
/* Function that reads from File 1 and appends it to File 3... (^) */ GnuFoo();
rwa read unlock(&f lock1); rwa read lock(&f lock2);
/* Function that reads from File 2 and appends it to File 3... (^) */ GnuBar();
rwa read unlock(&f lock2); rwa append unlock(&f lock3); }
Given that the above functions can run concurrently, is it possible for deadlock to occur? Suppose f lock1, f lock2, f lock3 are of type rwasem t and have been initialized. Rationalize your answer: