Os scheduling 2 | Computer Science homework help
4. PROGRAMMING
============== Now you're ready to implement the core of the scheduler, including the FIFO and Round Robin scheduling algorithms. For this purpose, you should only modify sched_impl.h and sched_impl.c. Please see scheduler.h for the descriptions of what functions you must implement. You are free to put whatever you want in the thread_info and sched_queue structures. Note that the only way that the functions you implement are made available to the main program is through the sched_impl_t structures sched_fifo and sched_rr. See dummy_impl.c for a completed example of how to fill in a sched_impl_t.
Suggested approach:
4.1 Create stub versions of all of the functions you will need to implement
in sched_impl.c, and statically initialize sched_fifo and sched_rr.
4.2 Figure out how you will implement the scheduler queue, add the
appropriate fields to struct sched_queue, and fill in the appropriate queue-related operations in the functions you created in (4.1). Remember that we provide a doubly-linked list in list.[hc].
4.3 Implement scheduler queue admission control, so that only the requested
number of threads can be in the scheduler queue at once. Create the appropriate synchronization constructs to prevent threads not in the queue from executing (look at the implementation of worker threads in scheduler.c:worker_proc()). 4.4 Implement the queue operations for selecting the next thread to execute. This will be different for FIFO vs. Round Robin scheduling.
4.5 Add in synchronization constructs to make sure only the selected thread
executes at any given time. 4.6 Fill in any gaps that might remain. When you think you're done, you can test your program using the command "make test". For more thorough testing, the fifo_var and rr_var tests accept queue_size, num_workers, and num_iterations arguments just like the
main program (but <num_iterations> is mandatory for the test case):
./scheduler -test fifo_var <queue_size> <num_workers> <num_iterations> ./scheduler -test rr_var <queue_size> <num_workers> <num_iterations>