Write a C++ program that simulates the operation of a simple operating system. Assume there are N jobs running in the system, all initially in the Ready Queue. At time zero, the first process is dispatched to the CPU and begins running. A running process may either:
This model is a simplified version of the "Queue-ing diagram" found on page 101 of our text, without the fork and generic interrupt options.
Please use a round-robin scheduling algorithm (page 163 of our text) to determine when processes are allotted CPU time. Processes are returned to the end of the Ready queue after the end of a CPU time slice or an I/O request.
Please use 10 milliseconds as your time slice for all simulations.
The input to your program will be a text file of process descriptions to be placed on the ready queue. The format of the file will be:
<process_id>
<cpu_burst> <io1_time> <io1_length> <io2_time>
<io2_length>
one process per line, where: |
<process_id> is the identifier for the process |
<cpu_burst> is the length of CPU burst needed for the process |
<io1_time> is the process CPU time at the first I/O request |
<io1_length> is the length of the first I/O request |
<io2_time> is the process CPU time at the second I/O request |
<io2_length> is the length of the second I/O request |
Note that I/O requests 1 and 2 are optional. Time and length values of zero means that no I/O is needed. For example, the line:
1 50 22 10 29 12
means that process ID #1 requires 50 total milliseconds of CPU time. After 22 milliseconds of CPU time, the process will block for I/O request #1, lasting 10 milliseconds. After another 7 milliseconds of CPU time (or 29 milliseconds of total CPU time), the process will block again for 12 milliseconds for the 2nd I/O request.
All processes are assumed to arrive at time zero, but in the order they appear in the file. Please ignore lines in the file that begin with #; these lines will be considered comments.
Here's an example file:
# This is the example from our text, page 173 |
# You can run this example and compare results to |
# what is shown in the text. No I/O in this one |
1 10 0 0 0 0 |
2 29 0 0 0 0 |
3 3 0 0 0 0 |
4 7 0 0 0 0 |
5 12 0 0 0 0 |
You will be expected to run your program on a set of data files of this format. These files will be located in the CSC 420 k: drive common folder:
k:/02SP/CSC420/Common Area/prog01/data/
Your output should include:
Echo the input file, so that I/you know what your input data was | |||||
For
each process, indicate:
|
For example, the output for the page 173 example input file above should be something like:
Process 1 completed at time 10 with a wait time of 0. |
Process 3 completed at time 23 with a wait time of 20. |
Process 4 completed at time 30 with a wait time of 23. |
Process 5 completed at time 52 with a wait time of 40. |
Process 2 completed at time 61 with a wait time of 32. |
Program #1 is worth 50 points, or 5% of your class grade.
Please place your source code, executable, and output data in a folder called "prog01" on your k: drive.
Your design of Program #1 is due Tue Apr 9.
Your design should minimally address the following questions/issues:
What classes are defined in your program? What are the public methods? | |
What is the flow (in pseudo-code) of your program? | |
How will system time be maintained? | |
How will process stats be maintained? | |
Our programs are not multi-processing or multi-threaded, so how will you simulate "interrupts" for I/O blocking, I/O completion, time slice completion, process CPU completion, etc. | |
Describe the startup of your program. How will you know that your simulation is done? |
So, please hand-in:
I hate to do it, but please print your headers and pseudo-code for grading/review.
Program #1 is due Thursday April 18.
Deliverables include:
You will be graded on:
Correctness of your results | |
Object-oriented design practices (though this does not mean I will take points off for not using the STL containers) | |
Clean code with understandable comments |
I am less interested in:
Efficiency - I won't be grading how fast or efficient your simulation is | |
Error handling - I won't be giving you any "bad" data sets | |
I/O - I don't care how elegantly you handle program parameters and don't bother gussying-up the output |
We will share design strategies and hints on Tuesday (so don't miss that class, eh).
Also, I will have the complete suite of test data by Tuesday as well.
Apr
16, 2002
Program is due on Thursday, the 18th. Please printout and hand in:
Please don't print out your code. I will check this on the k: drive. Also, I must be able to execute your program to verify your results. So, please make sure that an executable version of your program is available on the k: drive. Thanks... yow, bill
|
||||||||||||||
Apr
10, 2002
First off, the 3 datasets for program #1 are available in the Common Area of our k: drive. I'll copy them here for people working off-campus:
Also, you are certainly free to copy these files to your local folder, so that you don't have long path to type in each time you debug. We talked about a lot of things Tuesday. Here's a synopsis of some of the major "hints" or design approaches we discussed:
Make sure this weekend is a productive one and good luck! |