CS560 Final Exam - May 5, 2010

Answer all questions. You should note that although question 5 is by far the most time consuming question, it has a point value roughly equal to questions 2, 3 and 4, and far less than question 1. In other words, save it for last.


Question 1: Short Answers - 18 - 20 points

Question 2: (9 points): Describe RAID-0, RAID-1 and RAID-4, both in words and with pictures. In each, briefly detail the performance of large writes and the tolerance to failures.


Question 3 (10 points): In a demand paging operating system, give a listing of all the steps that the hardware and operating system go through when a user process tries to access a memory location that is not resident in memory, but is on disk. In each step, state whether it is done in the hardware or operating system. My answer had 13 steps, the first of which was "The program issues a load instruction for memory address x," and the last of which was "The instruction is finished." You may assume a standard paging scheme (i.e. not an inverted paging scheme), the specifics of which are unimportant.
Question 4 (8-9 points) In this question, suppose my virtual address space is laid out so that the first page is invalid, there are 2 pages of code, and 3 total pages of globals and heap that directly follow the code. The stack starts at some very large address which will not concern us.

If PTEs are four bytes and pages are 512 bytes, answer the following questions:





Question 5: (10 points) You are co-writing an operating system with a collection of colleagues. You are responsible for the scheduling algorithm. You are to implement the following four procedures: Note, you don't manage the currently running job -- your job is simply to manage the ready jobs, and to select which of the ready jobs should be run next.

Make the following assumptions:

Write the four procedures so that they implement a multi-level feedback queue. You may use C or C++, and if you'd like to use the STL, feel free to do so. I've included the syntax of the Dllist and JRB libraries below if you'd rather use them
dllist.h


typedef struct dllist {
  struct dllist *flink;
  struct dllist *blink;
  Jval val;
} *Dllist;

extern Dllist new_dllist();
extern void free_dllist(Dllist);
extern void dll_append(Dllist, Jval);
extern void dll_prepend(Dllist, Jval);
extern void dll_delete_node(Dllist);
extern int dll_empty(Dllist);

typedef struct jrb_node {
  struct jrb_node *flink;
  struct jrb_node *blink;
  Jval key;
  Jval val;
} *JRB;

extern JRB make_jrb();
extern JRB jrb_insert_str(JRB tree, char *key, Jval val);
extern JRB jrb_insert_int(JRB tree, int ikey, Jval val);
extern JRB jrb_insert_dbl(JRB tree, double dkey, Jval val);
extern JRB jrb_find_str(JRB root, char *key);
extern JRB jrb_find_int(JRB root, int ikey);
extern JRB jrb_find_dbl(JRB root, double dkey);
extern JRB jrb_find_gte_str(JRB root, char *key, int *found);
extern JRB jrb_find_gte_int(JRB root, int ikey, int *found);
extern JRB jrb_find_gte_dbl(JRB root, double dkey, int *found);
extern void jrb_delete_node(JRB node);
extern void jrb_free_tree(JRB root);