Results 1 to 2 of 2
Thread: Help with this problem.
- 04-28-2009, 03:39 PM #1Member
- Join Date
- Apr 2008
- Rep Power
Help with this problem.
I have this assignment that I need to do, but I don't really understand what am I supposed to do. Also,if you can help me with how the code should look like or how it would run I would be grateful.
One of the important issues in operating systems is that of scheduling jobs on a CPU. Assume that we have a single-processor machine. You are to build a program that schedules simulated CPU jobs. Your program should run in a loop, each iteration of which corresponds to a time slice for the CPU. Each job has an ID, which is a 8-character string, and is assigned a priority, which is an integer between 1 (highest priority) and 100 (lowest priority), inclusive. From among all jobs waiting to be processed in a time slice, the CPU must work on a job with highest priority. In this simulation, each job will also come with a length value, which is an integer between 1 and 100, inclusive, indicating the number of time slices that are needed to process this job. For simplicity, you may assume jobs cannot be interrupted—once it is scheduled on the CPU, a job runs for a number of time slices equal to its length (This CPU scheduling scheme is called non-preemptive). Your simulator must output the name of the job running on the CPU in each time slice and must process a sequence of commands, one per time slice, each of which is of the form "add job ID with length n and priority p" or "no new job this slice". Your program needs to do the following:
1. Reads a text file named cpu_jobs.txt that contains a sequence of commands to process. This text file is read via an argument that will be supplied to your java program when running it (for example, on a command line, you will enter "java testCPU cpu_jobs.txt" where testCPU is the Java test program).
2. Your program will output, for each time slice, the ID, priority, and time left for the process to finish in one line, and the second line will contain the command being processed at this time slice.
3. After executing all processes, your program shall print, for each process, the waiting time it took before using the CPU. At the end, it will print the average wait time for all processes. If no process was included in this session, your program shall print the message "CPU Idle in this session".
Using the implementation above, test your program for the following cases:
a) Use the length of the job, n, as its priority.
b) Use the value 101 - n as the job priority, where n is the length of the job.
c) Use an equal priority for all the jobs. In this case, they must be scheduled on a first-come first-serve basis. Note that this will, also, hold for all jobs with equal priorities in parts a) and b).
- 04-28-2009, 04:07 PM #2
pheonix... you've posted enough times in the forum to know that is not way to request help... specific answers for specific questions. You will probably be bombarded with "do your own homework" posts. So ...
- What have do done?
- What specific questions/problems do you have?
- Before commiting brain cells to code, write out on paper how the project should work, the flow, the different components, questions, how many classes will be needed, etc.
- Break the project into small parts and work on them individually (read from file, thread handling, time management, etc) and them integrate them. Don't try to program everything all at once.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.