






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!







Do not write in the boxes below.
I (xx/31) II (xx/31) III (xx/18) IV (xx/20) Total (xx/100)
What is the maximum possible number of cache misses, over all combinations of reference pat- tern and cache replacement policy? You do not need to justify your answer.
e->env_pgdir[0] = e->env_cr3 | PTE_P | PTE_W | PTE_U;
Fill in the three blanks below, and note that the definition below the question may be helpful: The above line exposes e’s (i) to e’s user-space code; that code sees the exposed data or data structures at virtual addresses (ii) through 2^22 − 1 (4 megabytes minus one), with the following associated memory permissions: (iii).
(i):
(ii):
(iii):
Here is a partial definition of struct Env:
struct Env { struct Trapframe env_tf; // Saved registers LIST_ENTRY(Env) env_link; // Free list link pointers envid_t env_id; // Unique environment identifier
........
// Address space pde_t *env_pgdir; // Kernel virtual address of page dir physaddr_t env_cr3; // Physical address of page dir
};
int $0x30 ; this is in lib/syscall.c
Before the line above, the environment has placed the system call number in %ax and the system call arguments in the other registers (%dx, %cx, etc.). If the JOS kernel has set up the IDT correctly, then, after the int call above, the processor begins executing in kernel mode, with the value of %cr3 after the transfer into kernel mode equal to the value of %cr3 before the transfer. Thus, after the transfer, the processor’s %cr3 points to an environment-specific page directory. Yet, the processor can load from, and store to, kernel memory—without generating page faults.
Why is there no page fault after the transfer? Which of the specific steps that you took, as part of doing the labs, ensures that page faults do not happen? Assume that the IDT is set up correctly (i.e., we are not asking about setting up the IDT). You do not need a lot of space; state your answer briefly below:
Circle ALL that apply:
A The environment id of the target. B The target’s data segment descriptor. C The physical address of the target’s page directory. D The virtual address that P should have in the target. E The physical address of P. F The permissions that the kernel should associate to the mapping.
A Overflows from addition of fixed-width integers B Starvation C Deadlock D Race conditions E Priority inversion F Performance problems from coarse-grained locking G Broken modularity from locking
State below how the algorithm works at a high level (you do not need to give pseudocode):
Identify the author or the reading:
int f_ran = FALSE; Mutex mutex; Cond cv;
// called by a thread Monitor::t1() { mutex.acquire(); if (f_ran == FALSE) cv.wait(&mutex);
g(); /* <-- It is an error if g() executes before f() */
mutex.release(); }
// called by another thread Monitor::t2() { mutex.acquire();
f(); f_ran = TRUE;
cv.broadcast(&mutex); mutex.release(); }
Under which conditions is the above pseudocode correct? Circle the BEST answer:
A The code executes on a single processor. B The memory model is sequential consistency. C The threads are user-level threads. D The system contains only two threads, one that calls t1() and one that calls t2(). E The broadcast() is replaced with a signal(). F The code is correct if conditions A, C, and D all hold simultaneously. G The code is correct if conditions B and D both hold simultaneously. H The code is correct if conditions A, C, D, and E all hold simultaneously. I None of the above.
Does the code above violate requirement (i)? In other words, can alloc foo() be called more than once from doublecheck alloc()? If so, give an interleaved execution or an interleaving of memory operations as observed by one of the threads. If not, argue from invariants.
Does the code above violate requirement (ii)? In other words, can the caller of doublecheck alloc() observe ptr == 0 after doublecheck alloc() returns? If so, give an interleaved execution or an interleaving of memory operations as observed by one of the threads. If not, argue from invariants.