Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming language: Java Use AVLTree In this assignment, you will implement a basic Process Scheduler, where each process will get a little bit of time

Programming language: Java

Use AVLTree

In this assignment, you will implement a basic Process Scheduler, where each process will get a little bit of time to execute before allowing the next process to run. The amount of time each process gets will be based on its priority (0-9, 0 being the highest, and 9 being the lowest). A task with a priority of 0 will get 10 milliseconds to execute, and a task with a priority of 9 will get 1 millisecond to execute. Each process will need to run to completion, keeping track of when it started and when it finished, so that the total runtime for a process can be determined and displayed 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 implementing BST 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 process based on its priority (i.e. 0

    priority gets 10 seconds, 9 priority gets 1 second)

o ThusduringthefirsttimethroughtheTree,theprocesswithPriority0gets10

milliseconds to execution time, then the two process with Priority of 2 get 8 miliseconds each, and so on (use Thread.sleep(milliseconds) to sleep the process as you need to know the total time it took for a process to complete.) Each process gets a chance to execute, just for less and less time, so that the top priority processes get more time to execute.

o If a process is not complete, then it needs to stay in the Tree o Keep running through the Tree until all processes have completed executing

o Keep track of completed processes so that you can print them at the end

  • Display each completed process, and the runtime that it took for each to complete

  • Processes will need to know when they started and when they stopped 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 Process Remaining Runtime: 70

Level 1 > Process Name: clang Process Id: 8 Process Priority: 2 Process Remaining Runtime: 100

Process Name: perl Process Id: 77 Process Priority: 8 Process Remaining Runtime: 33

Level 2 > Process Name: gcc Process Id: 4 Process Priority: 0 Process Remaining Runtime: 25

Process Name: llvm Process Id: 44 Process Priority: 2 Process Remaining Runtime: 22

Process Name: pythn Process Id: 16 Process Priority: 5 Process Remaining Runtime: 77

Process Name: javac Process Id: 45 Process Priority: 9 Process Remaining Runtime: 50

Level 3 > Process Name: cc Process Id: 20 Process Priority: 4 Process Remaining Runtime: 55

Process Name: ada Process Id: 33 Process Priority: 6 Process Remaining 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions