Project 2b: xv6 SchedulerObjectivesThere are two objectives to this assignment:
OverviewIn this project, you'll be implementing a simplified multi-level feedback queue (MLFQ) scheduler in xv6. The basic idea is simple. Build an MLFQ scheduler with four priority queues; the top queue (numbered 0) has the highest priority and the bottom queue (numbered 3) has the lowest priority. When a process uses up its time-slice, it should be downgraded to the next (lower) priority level. The time-slices for higher priorities will be shorter than lower priorities. DetailsYou have three specific tasks for this part of the project. Implement MLFQ: Your MLFQ scheduler will be very simple and will not have any mechanisms to prevent gaming or starvation. Specifically, your MLFQ scheduler should follow these very precise rules:
Create getpinfo(): You'll need one new system call for this project: int getpinfo(struct pstat *) . This routine returns some basic information about each process: its process ID, how many times it has been chosen to run, and which queue it is currently on (0, 1, 2, or 3). To do this, you will need to fill in the pstat structure as defined here: here. Do not change the names of the fields in pstat.h Make a graph: You should make a graph that shows some timelines of processes running with your scheduler, including which queue each process is on, and how much CPU they received. To obtain the info for your graph, you should use the getpinfo() system call. Make up a workload (or set of workloads) that vary how long each process uses the CPU before voluntarily relinquishing the CPU (e.g., by calling sleep()). Think about what types of workloads will show interesting and useful results. Use the graphs to prove to us that your scheduler is working as desired. TipsMost of the code for the scheduler is quite localized and can be found in proc.c ; the associated header file, proc.h is also quite useful to examine. To change the scheduler, not much needs to be done; study its control flow and then try some small changes. As part of the information that you track for each process, you will probably want to know its current priority level and the number of timer ticks it has left (before it will be demoted to the next lower priority or, if it is already at the lowest priority, moved to the end of the round-robin queue). You'll need to understand how to fill in the structure pstat in the kernel and pass the results to user space. The structure looks like what you see in here. The CodeThe source code for xv6 (and associated README) can be found in ~cs537-1/ta/xv6/ . Everything you need to build and run and even debug the kernel is in there. You may also find the following readings about xv6 useful, written by the same team that ported xv6 to x86: xv6 book. What To Turn InBeyond the usual code, you'll have to make a graph for this assignment. You can use whatever graphing tool you would like ("gnuplot" is a fine, basic choice). When you have your graph, please create a .pdf version of it and place it in a file named graph.pdf. If you have multiple graphs, name them graph1.pdf, graph2.pdf and so one. Please describe the workload that you ran to create your graph and explain why your graph shows the results that it does. You can either put this explanatory text directly in graph.pdf or in a separate file workload.pdf or workload.txt (if you use plain text). These are the only formats and filenames you should use. |