Be sure you have read Chapter 2, sections 2.4 through 2.5.
Answer the following questions. You may write out your answers by hand or using a word processor or other program, but please submit hard copy, either in class or in my mailbox in the department office.
job | running time | priority |
---|---|---|
10 | 3 | |
6 | 5 | |
2 | 2 | |
4 | 1 | |
8 | 4 |
For each of the following scheduling algorithms, determine the turnaround time for each job and the average turnaround time. Assume that all jobs are completely CPU-bound (i.e., they do not block). (Before doing this by hand, decide how much of programming problem 1 you want to do.)
/* woman process */ while (TRUE) { woman_enter(); use_restroom(); woman_leave(); do_other_stuff(); } /* man process */ while (TRUE) { man_enter(); use_restroom(); man_leave(); do_other_stuff(); }You can use any of the synchronization mechanisms we have talked about (shared variables, semaphores, monitors, or even message passing).
Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course number and the assignment (e.g., ``csci 3323 homework 3''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.
I chose C++ for the starter code because in theory all of you have had at least some exposure to C++, and this might be a good opportunity for you to dust off that skill. The starter code also makes use of some library classes (string and vector) that you may not have worked with before. string is functionally pretty similar to strings in languages such as Java; vector represents a templated expandable array (i.e., one with a type parameter that lets you specify the type of elements in the array). I'm cautiously optimistic that between the starter code, this toy example of using vector, and what you can find on the Web about these classes (the Wikipedia articles seem okay), you will be able to use them to implement your choice of scheduling algorithm(s). If you don't remember, or didn't learn, how to compile C++ from the command line in Linux:
g++ -Wall -pedantic scheduler.cpp
However, feel free to rewrite anything about this program, including starting over in a language of your choice. Just remember that the program has to run on one of the department Linux machines, and it needs to accept input from command-line arguments and files -- i.e., no GUIs, Web-based programs, etc. The latter requirement is to make it possible for me to automate testing your code. If you make changes to the format of the input -- and I prefer that you don't -- change the comments so they describe the changed requirements.