ICS 160E / EECS 114 - Engineering Data Structures and Algorithms- Programming Project 3

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

ICS 160E / EECS 114 - Engineering Data Structures and Algorithms - Programming Project 3

In this project you are to build a Java 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 is assigned a priority, which is an integer between -20 (highest priority) and 19 (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. 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 one the following forms:

  • add name n p
    which adds the new job, name, with length n and priority p. For example, the following command adds a job DogFace of length 15 and priority 5:
    add DogFace 15 5
    
  • continue
    which indicates that there is no new job for this time slice.
  • kill name
    which kills the job, name, that is, it removes it from the collection of waiting jobs. If the job, name, is the one currently running, it stops it and starts performing the next highest-priority job waiting to be performed.

Note: you may use the following class in your program:

You should read commands from System.in and output the name of the job running in each time slice to System.out.

发表评论

电子邮件地址不会被公开。 必填项已用*标注