Programming Language Java Use Avltree Assignment Implement Basic Process Scheduler Process Q43811935
Programming language: Java
Use AVLTree
In this assignment, you will implement a basic ProcessScheduler, where each process will get a little bit of time toexecute before allowing the next process to run. The amount of timeeach process gets will be based on its priority (0-9, 0 being thehighest, and 9 being the lowest). A task with a priority of 0 willget 10 milliseconds to execute, and a task with a priority of 9will get 1 millisecond to execute. Each process will need to run tocompletion, keeping track of when it started and when it finished,so that the total runtime for a process can be determined anddisplayed at the end.
Assignment Description
The program will need to perform the following tasks:
-
Display your name and email address as the first output
-
Display the following text after your name “Name”
-
Create the ProcessInfo class listed below
o Create necessary getters/setters for the class variables
-
Implement the AVL Tree class from 996 (will require implementingBST and Tree)
-
Read the process information from a file (sample provided)
o CreateaprocessInfoobjectforeachprocessinthefile
-
Add these processInfo objects to an AVL Tree
-
Print a sample of the Tree by level
-
Run through the processes, allocating time for each processbased on its priority (i.e. 0
priority gets 10 seconds, 9 priority gets 1 second)
oThusduringthefirsttimethroughtheTree,theprocesswithPriority0gets10
milliseconds to execution time, then the two process withPriority of 2 get 8 miliseconds each, and so on (useThread.sleep(milliseconds) to sleep the process as you need to knowthe total time it took for a process to complete.) Each processgets a chance to execute, just for less and less time, so that thetop priority processes get more time to execute.
o If a process is not complete, then it needs to stay in theTree
o Keep running through the Tree until all processes have completedexecuting
o Keep track of completed processes so that you can print themat the end
-
Display each completed process, and the runtime that it took foreach to complete
-
Processes will need to know when they started and when theystopped executing.
(page 842 is one example for how to do this)
-
Recall that an BST/AVL Tree will not allow for duplicate items,but some of your
processes have the same priority.
ProcessInfo
String processName
int processId
int ProcessPriority
int processRemainingRuntime
long processStartTIme
long processEndTIme
long processElapsedTime
+ ProcessInfo()
+ executeProcess(int) : boolean
+ compareTo(ProcessInfo) : int
+ toString() : String
+ displayCompletedInfo() : String
– endProcess() : void
Sample Run
Level 0 >
Process Name: javac Process Id: 20 Process Priority: 3 ProcessRemaining Runtime: 70
Level 1 >
Process Name: clang Process Id: 8 Process Priority: 2 ProcessRemaining Runtime: 100
Process Name: perl Process Id: 77 Process Priority: 8 ProcessRemaining Runtime: 33
Level 2 >
Process Name: gcc Process Id: 4 Process Priority: 0 ProcessRemaining Runtime: 25
Process Name: llvm Process Id: 44 Process Priority: 2 ProcessRemaining Runtime: 22
Process Name: pythn Process Id: 16 Process Priority: 5 ProcessRemaining Runtime: 77
Process Name: javac Process Id: 45 Process Priority: 9 ProcessRemaining Runtime: 50
Level 3 >
Process Name: cc Process Id: 20 Process Priority: 4 ProcessRemaining Runtime: 55
Process Name: ada Process Id: 33 Process Priority: 6 ProcessRemaining Runtime: 44
Results >
Process Name: gcc Process Priority: 0 Completion Time: 122
Process Name: llvm Process Priority: 2 Completion Time: 139
Process Name: javac Process Priority: 3 Completion Time: 403
Process Name: cc Process Priority: 4 Completion Time: 404
Process Name: ada Process Priority: 6 Completion Time: 436
Process Name: clang Process Priority: 2 Completion Time: 464
Process Name: pythn Process Priority: 5 Completion Time: 494
Process Name: perl Process Priority: 8 Completion Time: 499
Process Name: javac Process Priority: 9 Completion Time: 542
Expert Answer
Answer to Programming language: Java Use AVLTree In this assignment, you will implement a basic Process Scheduler, where each proc…
OR