Project #2Assigned: February 18Due: March 11, 3:00pm, in class Problem(100 points) Design and implement a program (in any language) which simulates some of the job scheduling, CPU scheduling, and semaphore processing of an operating system.Detailed Description and RequirementsWhen jobs initially arrive in the system, they are put on the job scheduling queue which is maintained in FIFO order. The job scheduling algorithm is run when a job arrives or terminates. Job scheduling allows as many jobs to enter the ready state as possible given the following restriction: a job cannot enter the ready state if there is not enough free memory to accommodate that job's memory requirement. Do not start a job unless it is the first job on the job scheduling queue. When a job terminates, its memory is released, which may allow one or more waiting jobs to enter the ready state. A job can only run if it requires less than or equal to the system's main memory capacity. The system has a total of 512 blocks of usable memory. If a new job arrives needing more than 512 blocks, it is rejected by the system with an appropriate error message. Rejected jobs do not factor into the final statistics (described below). Note that all jobs in the ready state must fit into available main memory. Process scheduling is managed as a multilevel feedback queue. The queue has two levels, both using a round robin scheduling technique. New jobs are put on the first level when arriving in the ready state. When a job from the first level is given access to the CPU, it is allowed a quantum of 100 time units. If it exceeds that time quantum, it is preempted and moves to the second level. The jobs on the second level may only be allocated the CPU if there are no jobs on the first level. When a job on the second level is given access to the CPU, it is allowed a quantum of 300 time units. If it exceeds that, it is preempted and put back on the second level of the ready queue. Process scheduling decisions are made whenever any process leaves the CPU for any reason (e.g., expiration of a quantum or job termination). When a job terminates, do job scheduling first, then process scheduling. Also, give preference to first level jobs, i.e., if a job from the second level of the ready queue is running, and a new job enters the first level, the running job is preempted to the second level in favor of the first level job. While executing on the CPU, a job may require I/O, which preempts it to the I/O wait queue for the duration of its I/O burst. While executing on the CPU, a job may perform a semaphore operation. Assume there are 5 semaphores shared among all jobs running in the system, numbered 0 through 4, each initialized to 1. If a job must wait because of a semaphore, it goes onto the appropriate wait queue until it is signaled. There is a separate wait queue for each semaphore. When a job completes, put it on a finished list for later processing. The simulator is driven by the events read from standard input. Examples of possible events are given below. The first field will be the first character of the line, and subsequent fields will be separated by one of more spaces or tabs. The header of each field in the following examples does not appear in the input file. A new job arrives:Event Time Job Memory Run Time A 140 12 24 2720 Interpretation: job 12 arrives at time 140, requires 24 blocks of memory and uses the CPU for a total of 2720 time units. A job needs to perform I/O:Event Time I/O Burst Time I 214 85 Interpretation: the job currently running on the CPU will not finish its quantum because at time 214 it needs to perform I/O for a duration of 85 time units. A job performs a wait on a semaphore:Event Time Semaphore W 550 2 Interpretation: the job currently running on the CPU performs a wait on semaphore number 2 which may or may not cause it to be preempted. Initialize each semaphore to 1. A job performs a signal on a semaphore:Event Time Semaphore S 622 2 Interpretation: the job currently running on the CPU performs a performs a signal on semaphore number 2 which may allow a job to re-enter the ready state. Display the status of the simulator:Event Time D 214 Interpretation: display the status of the simulator at time 214. You may assume that events appear on the input stream in ascending time order and no two events happen at the same time. However, realize that the events given in the input stream are not only events which your simulator must handle. For instance, a time quantum expiration is not an event given in the input stream, but it is an event which your simulator must handle. Furthermore, an internal event, such as a time quantum expiration, not in the input stream, may occur at the same time as an event in the input stream, e.g., a new job arrival. Events in the input stream are external events. The following is a list of internal events (i.e., not given on the input file) which your simulator must handle:
Assume that context switching, semaphore operations, and displays take no simulator time (an unrealistic assumption in a real operating system). When a display is requested, print the contents of all queues as well as the job currently running on the CPU to standard output using only the format used in the sample output given below. After processing all jobs, write the following to standard output (in this order, as shown on the sample output given below):
Event CollisonsOften more than one event happen at the same time. Use the following rules to determine which events to process first:
Graphical View of the Simulator
Additional Requirements
Hints and notes
Test data: sample input and outputUse the UNIX diff utility to compare your output to the correct output. For full credit, the output produced by your program must have zero differences, as defined by diff, with the output posted here.When developing your simulator, you are encouraged to get it to work on the simple test data first (p2d.dat) and progressively refine your program to the point where it works on the most complex test data (p2a.dat). How to submitNote: All directory and filenames below are case-sensitive. You must use the directory and filenames exactly as shown below, i.e., all lower case.
EvaluationNinety percent of your score will come from correctness and 10% of your score will come from following our programming style guide. Applicable submission penalties will then be applied. Students earn up to four different portions of the 90 possible points for correctness:
|
