# 2D Game

## Question

Task 1. NP_PRIORITY for the non-preemptive priority algorithm. Hint: you can re-use the FCFS function - it can be implemented as a call to FCSF after sorting the process queue in the order of priority. The getPriority function is provided for use as key of the sort(). Use inverse priority i.e. less the priority number, higher is the priority level.

Task 2. SJF for shortest job first algorithm. Hint: you can re-use the FCFS function - it can be implemented as a call to FCSF after sorting the process queue in the order of burst time. The getBurstTime function is provided for use as key of the sort().

Demo 1: Student should also be able to answer questions about the given code (they should read and understand it in advance). Sample question: in the given code "as is", what is the arrival time(s) of the three processes used as input data? What will you change in the code to decrease the priority of process with PID=2, to level 5?
Demo 2: Show how the two tasks were done (partial completion is ok) and answer questions about the code that was written.
The functions defined by you MUST be named exactly as NP_PRIORITY and SJF.
The functions NP_PRIORITY and SJF must take a ready queue as argument. The ready queue is a list of Process objects in the order of arrival (this is the same as what FCFS accepts as argument).
All functions must return the list of Process objects so that printStats( ) can accept that returned value (this is the same as what FCFS returns).
The Process class and the printStats( ) function definitions cannot be modified.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import copy

class Process:

def __init__(self,pid,bt,at=0,pr=0):
self.pid = pid
self.burst_time = bt
self.arrival_clock_time = at
self.priority = pr
self.remaining_burst_time = bt

def __str__(self):
return "Process (PID="+str(self.pid)+")"

def sim_run(self):
self.remaining_burst_time -= 1

def is_done(self):
return self.remaining_burst_time == 0...
\$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.