Answered You can hire a professional tutor to get the answer.

QUESTION

Project 2: Scheduling in Minix Purpose The main goal for this project is to modify the MINIX 3 scheduler to be more flexible. You must implement a...

Project 2: Scheduling in MinixPurposeThe main goal for this project is to modify the MINIX 3 scheduler to be more flexible. You must implement a lottery scheduler.This project will also teach you how to experiment with operating system kernels, and to do work in such a way that might crash a computer. You'll get experience with modifying a kernel, and may end up with an OS that doesn't work, so you'll learn how to manage multiple kernels, at least one of which works. BasicsThe goal of this assignment is to get everyone up to speed on modifying MINIX 3 and to gain some familiarity with scheduling. In this assignment you are to implement a lottery scheduler.A lottery scheduler assigns each process some number of tickets, then randomly draws a ticket among those allocated to ready processes to decide which process to run. That process is allowed to run for a set time quantum, after which it is interrupted by a timer interrupt and the process is repeated. The number of tickets assigned to each process determines both the likelihood that it will run at each scheduling decision as well as the relative amount of time that it will get to execute. Processes that are more likely to get chosen each time will get chosen more often, and thus will get more CPU time.DetailsUnless explicitly specified, all source code can be found in /usr/src/.In this project, you will modify the scheduler for MINIX. This should mostly involve modifying code in kernel/proc.c specifically the sched() and pick_proc() functions (and perhaps enqueue() and dequeue() ). You may also need to modify kernel/proc.h to add elements to the proc structure and modify queue information (NR_SCHED_QUEUES, TASK_Q, IDLE_Q, etc.) and may need to modify PRIO_MIN and PRIO_MAX in /usr/include/sys/resource.h. Process priority is set in do_getsetpriority() in servers/pm/misc.c, which calls do_nice() in kernel/syste/do_nice.c. You might be better off just using the nice() system call , which calls do_nice() directly. You'll probably want to modify what do_nice() does—for lottery scheduling, nice() can be used to assign or take away tickets. The current MINIX scheduler is relatively simple. It maintains 16 queues of "ready" processes, numbered 0–15. Queue 15 is the lowest priority (least likely to run), and contains only the IDLE task. Queue 0 is the highest priority, and contains several kernel tasks that never get a lower priority. Queues 1–14 contain all of the other processes. Processes have a maximum priority (remember, higher priorities are closer to 0), and should never be given a higher priority than their maximum priority. You're going to need to add 1 queues to the existing 16 for a total of 17 queues. The easiest solution is to use the top 16 queues for system processes using the existing code, and to use the new queue for user processes. You can identify system processes by seeing if the SYS_PROC bit is set in a process's p_priv->s_flags variable. Lottery SchedulingFor this project I want you to use lottery scheduling as described in class. System processes (queues 0–14) are run using their original algorithm, and queue 15 still contains the idle process. However, queue 16 contains all of the runnable user processes, each of which has some number of tickets. The default number of tickets for a new process is 5. However, processes can add or subtract tickets by calling setpriority(ntickets), which will increase the number of tickets by ntickets (note that a negative argument will take tickets away). A process cannot accumulate more than 100 tickets, and must always hold at least 1 ticket. Each time the scheduler is called and a user process is to be run, it should randomly select a ticket (by number) and run the process holding that ticket. Clearly, the random number must be between 0 and nTickets-1, where nTickets is the sum of all the tickets belonging to processes in the ready queue (processes that are blocked are ineligible to run). You may use the random() call (you may need to use the random number code in /usr/src/lib/other/random.c) to generate random numbers and the srandom() call to initialize the random number generator. A good initialization function to use would be the current date and time. New processes are created and initialized in kernel/system/do_fork.c. This is probably the best place to initialize any data structures.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question