Question |
Max |
Grade |
T/F |
10 pts. |
|
1-5 |
20 pts. |
|
6-10 |
20 pts. |
|
11. |
10 pts. |
|
12. |
10 pts. |
|
13. |
15 pts. |
|
14. |
15 pts. |
|
Total: |
100 pts. |
____ The page-table register is updated every time there is a
context switch from one thread to another.
____ There is a stack for every thread in the process.
____ mmap() returns NULL if there is an error.
____ Two VM pages in the same process could map to the same physical
page.
____ The backing-store of the Stack is swap space.
____ sbrk(0) will return a pointer to the end of the heap.
____ An object returned by malloc could have an address that ends in
"2" .
____ cond_signal could wake up more than one thread.
____ The stack of one thread could potentially be modified by another
thread.
____ mmaped memory that is modified is immediately updated in the
mapped file.
2. (4 pts) Enumerate the fields of an i-node.
3. (4 pts) Give an example in "C" of a premature free.
Give an
example in "C" of a memory leak.
4. (4 pts) Explain how you could modify your memory allocator to
detect "memory smashing".
5. (4 pts) Explain how VM memory speeds up the allocation of
zero-initialized memory for stack or heap.
6. (4 pts) Explain how the modified
clock algorithm works to
approximate LRU.
7. (4 pts) What are the advantages and disadvantages of hard links
vs. symbolic links?
8. (4 pts) Explain how VM memory speeds up the execution of
fork().
9. (4 pts) Explain why the malloc libraries may have problems
return memory back to the OS.
11. (10 pts)
Write a program "grepsortout arg1 arg2 arg3" that executes the
shell command "grep arg1 arg2 | sort > arg3" in the program using
fork, execvp, pipe, dup2, and any other call you need. arg1, arg2, and
arg3 are passed through argv. Print any error to stderr and print a
diagnostic using perror(). |
int main( int argc, char ** argv) { } |
12. (10
pts) From your lab5, write the C++ function <>int
RPCServer::RPCServer( char *
sharedFileName );
> |
int
RPCServer::RPCServer( char *
sharedFileName ) {
} |
13. (15 pts) From lab7 from the method "int void
Allocator::freeObject( void * ptr )"
write the part that checks if the object at the left of "ptr" is free
and coalesces it if necessary. If you
need
helper functions also include them in your implementation. Note: Only
write this part of the code. |
void // Check if the object at the
left of "ptr" is free and
} > |
14. (15 pts) Write
a class WaitForAlert that allows threads to wait for an alert until an
alert is produced. Alerts have names of type (char *). A thread calling
waitForAlert(alertName) will wait until another thread calling
signalAlert(alertName) with the same alertName is called. For example,
multiple threads can call waitForAlert("aaaa") and all these threads
will block until another thread calls signalAlert("aaaa"). If
signalAlert(alertName) is called and no threads are waiting for this
alertName, the signalAlert() call will be ignored. IMPORTANT: Use condition variables. |
class WaitForAlert { // Add your member variables here public: WaitForAlert(); void waitForAlert(const char * alertName); void signalAlert(const chat *alertName); }; WaitForAlert::WaitForAlert() { } void WaitForAlert::waitForAlert(const char * alertName) { } void WaitForAlert::signalAlert(const chat *alertName) { } |