proj02
Process scheduling

ITEC371 (OS), 2015fall-mhtay

Due 2015-Mar-18 (Wed)22 (Sun) 23:59, D2L and hardcopy (in following class)

Design and implement a program that simulates CPU scheduling techniques in UNIX environment. CPU scheduling is a fundamental operating ­system function. It is the allocation of CPU time to processes in multi programmed operating systems. The allocation scheme could be different from one system to another depending on their scheduling algorithms. Although this CPU scheduling project is not as complicated as in real operating systems, it allows you to design your own CPU scheduling policy.

Scheduling Policy:

You are required to implement a Multilevel Queue scheduling algorithm in this project. The general descriptions of this algorithm can be found in Silberschatz §5.3.6. The following are specific requirements of this project:

  1. The ready-queue is partitioned into three separate queues: the foreground, intermediate, and background queue. All queues are scheduled by the round-robin scheduling algorithm (Silberschatz § 5.3.4).
  2. New processes are added to the foreground queue. These processes will be assigned to the CPU in round-robin fashion. However, if a process has been assigned to the CPU for a certain quantum time and yet has not finished its execution, then the process will be re­allocated to the intermediate queue. Then, again if the process from the intermediate queue has not finished its execution after being assigned to CPU for a certain quantum time, the process will be shifted to the background queue. At the background queue, the roundrobin scheduling mechanism will be applied until the process finishes its execution. (Note that you may use the priority field in the PCB structure as a counter of the number of times the process has been assigned to the CPU).
  3. Use a fixed-priority preemptive scheduling scheme: no process in the intermediate queue could run unless the foreground queue is empty. Likewise, a process in the background queue will not be allocated to the CPU unless the intermediate queue is empty. If a process enters the foreground queue during the execution of a process from the intermediate or background queues, the running process must be preempted and put back to the end of the appropriate queues; the preempted process may be put back to its old queue or to the new queue following the rule in the first requirement depending on the number of times it was assigned to the CPU.


Instructions


1 As always: If you use bits of code found on the web (say, processing command-line arguments and default values, or using pseudo-random number generators effectively), always be sure to cite your source.      

2 To avoid “petering out” effects, your simulation may generate more jobs that start but don't finish within the simulation.      

3 Depending on the exact distribution you use, this need not actually be the average. However, it should correlate with the average job-length.