NEW: For a prettier blog interface, see the Wordpress version!

Individual OS project

Did 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 list
In 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

./prosim list

If "prosim.dat" exists in the current directory, display its contents. If not, print out "No data yet."

Process simulation

./prosim fcfsFirst Come First Serve (non-preemptive). Ignore the priority.
./prosim sjfShortest Job First (non-preemptive). Ignore the priority.
./prosim srtfShortest Remaining Time First (preemptive). Ignore the priority.
./prosim prioritynpPriority (non-preemptive)
./prosim prioritypPriority (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).

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:

Each submission is required.

Feel free to e-mail questions to [email protected]

Previous day | Next day

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 [email protected] .

Page: C S 161.Shell Scripting Project
Updated: 2004-11-21
NOTE: ANTI-SPAM MEASURE NOW IN PLACE. Please answer the following question with the right number in order to send me your comment.
What is two minus one? (hint: one ;) )
Name:
E-mail:
URL:
Comments: