NEW: For a prettier blog interface, see the Wordpress version!
Individual OS projectDid you feel a little out of place while your groupmates worked on the first shell scripting project? Do you feel guilty about not having been able to contribute your share? Here's a small, simple shell-scripting project that you can do to improve your skills and salvage your grade!
Objective
After this short project, you will be able to use basic UNIX shell scripting commands and concepts to write simple, convenient tools. This project will also help you work on the second official project.
Description
Write prosim, a simple shell-scripted process simulator. It will store its data in a plain-text file named prosim.dat in the current directory.
Your program must support at least the following commands:
./prosim help ./prosim clear ./prosim add <processId> <arrivalTime> <cpuBurstTime> <priority> ./prosim listIn addition, pick any combination of the following commands and implement them. See the Grading section for details on the point breakdown.
./prosim fcfs ./prosim sjf ./prosim srtf ./prosim priorityp ./prosim prioritynp ./prosim rr <quantum>See the Details section for implementation details.
Details
Essential commands
./prosim help
This command should display a short help message and credits. An example follows. (Delete the lines that do not apply to your program.)
prosim - a simple process simulator by Your Name <your@email> Commands: ./prosim help ./prosim clear ./prosim add <processId> <arrivalTime> <cpuBurstTime> <priority> ./prosim fcfs ./prosim sjf ./prosim srtf ./prosim priorityp ./prosim prioritynp ./prosim rr <quantum>
./prosim clear
This command should delete "prosim.dat" if it exists. If it does not exist, nothing should be printed out.
./prosim add <processId> <arrivalTime< <cpuBurstTime< <priority>
This command should add the specified process to the end of "prosim.dat". The data should be stored in the form
processId,arrivalTime,cpuBurstTime,priority
- Process ID: A number.
- Arrival time: Given in terms of CPU cycles
- CPU burst time: The number of CPU cycles this process will consume.
- Priority: A number. A program with a higher priority should override a program with a lower one
./prosim list
If "prosim.dat" exists in the current directory, display its contents. If not, print out "No data yet."
Process simulation
| ./prosim fcfs | First Come First Serve (non-preemptive). Ignore the priority. |
| ./prosim sjf | Shortest Job First (non-preemptive). Ignore the priority. |
| ./prosim srtf | Shortest Remaining Time First (preemptive). Ignore the priority. |
| ./prosim prioritynp | Priority (non-preemptive) |
| ./prosim priorityp | Priority (preemptive) |
| ./prosim rr | Round-robin with the given time quantum. Ignore the priority. |
Perform the specified simulation using the processes specified in "prosim.dat". Display the process simulation, a summary of waiting and turnaround times, and averages. Use the format below:
TIME <time>,<process being run (blank if idle)> TIME <time>,<process being run (blank if idle)> TIME <time>,<process being run (blank if idle)> ... PROCESS <id>,<totalWaitingTime>,<turnaroundTime> PROCESS <id>,<totalWaitingTime>,<turnaroundTime> PROCESS <id>,<totalWaitingTime>,<turnaroundTime> ... AVERAGE WAITING TIME: <averageWaitingTime> AVERAGE TURNAROUND TIME: <averageTurnaroundTime>You may store temporary data in "prosim.tmp" and "prosim.tmp2".
See the sample execution run for more details.
Sample execution run
$ ./prosim clear $ ./prosim add P1 0 4 3 $ ./prosim add P2 0 1 0 $ ./prosim add P3 1 3 1 $ ./prosim add P4 10 3 5 $ ./prosim list P1,0,4,3 P2,0,1,0 P3,1,3,1 P4,10,3,5 $ ./prosim fcfs TIME 0,P1 TIME 1,P1 TIME 2,P1 TIME 3,P1 TIME 4,P2 TIME 5,P3 TIME 6,P3 TIME 7,P3 TIME 8, TIME 9, TIME 10,P4 TIME 11,P4 TIME 12,P4 PROCESS P1,0,4 PROCESS P2,4,5 PROCESS P3,4,7 PROCESS P4,0,3 AVERAGE WAITING TIME: 2 AVERAGE TURNAROUND TIME: 4
Score
The maximum score on this project is 95 (as it is, after all, a second chance).
- 30 points will be given for the basic functionality.
- Up to 60 points will be given for the correct implementation of any of the following scheduling algorithms.
./prosim fcfs 15 points ./prosim sjf 20 points ./prosim srtf 20 points ./prosim prioritynp 20 points ./prosim priorityp 20 points ./prosim rr 20 points - 5 points will be given for error-checking.
Acceptable behavior
You may ask other people for help in terms of pseudocode and ideas about which command to use. You may also ask for their help in debugging.
BUT:
If you want to get the most out of your CS161 education, you must type every single line of code in your prosim shell script yourself, _without_ referring to other people's code whether in electronic or paper form. I want you to be able to confidently say that this is your work.
You are encouraged to delete and retype your work until the above condition is satisfied.
Other notes
If you feel somewhat guilty working on this while your groupmates are working on the incredibly difficult final project, reassure them that they'll be able to use your work. In fact, show them the specs for this assignment and have the more advanced programmers find a way to incorporate the results of your work into their program. I can test everyone's work on a Linux system, so feel free to use shell scripts.
Submission
E-mail your prosim shell script to me by 11:59:59 PM of each deadline. Here are the deadlines:
- January 28: Basic prosim.sh with help, clear, add and list.
- February 4: At least one scheduling algorithm
- February 9: At least another scheduling algorithm
- February 11: With error-checking. FINAL SUBMISSION
Each submission is required.
Feel free to e-mail questions to sacha@sachachua.com
I'd love to hear about any questions, comments, suggestions or links that you might have. Your comments will not be posted on this website immediately, but will be e-mailed to me first. You can use this form to get in touch with me, or e-mail me at sacha@sachachua.com .