Round-Robin CPU scheduling is described. ((Write_) a… Round-Robin CPU scheduling is described. ((Write_) a functionround_robin to simulate this job scheduling model. This function receives a job queue, which is aListQueue object, as an argument. Each job in this job queue is an integer, which represents the number of time units needed to finish the job. Theround_robin function will process each job in the queue one by one. Each job will have a time slice of 10 units. Do the following for the job at the front of the queue:Display the time units needed to finish the jobIf it is 10 or less, display “Job finished” and move on to process next job.If it is more than 10, subtract 10 from it, display “Job unfinished. Return to the rear of the queue.” and return the unfinished job to the rear of the queue. Move on to process next job.Display the updated job queue.Repeat this until the job queue is empty.Please ((complete)) the definition of the functionround_robin and use the functiontest_round_robin to test your work. Do not make other changes to the file. Expected output:Initial job queue: {17, 5, 32, 8, 24}Current job: 17Job unfinished. Return to the rear of the queue.Job queue: {5, 32, 8, 24, 7}Current job: 5Job finishedJob queue: {32, 8, 24, 7}Current job: 32Job unfinished. Return to the rear of the queue.Job queue: {8, 24, 7, 22}Current job: 8Job finishedJob queue: {24, 7, 22}Current job: 24Job unfinished. Return to the rear of the queue.Job queue: {7, 22, 14}Current job: 7Job finishedJob queue: {22, 14}Current job: 22Job unfinished. Return to the rear of the queue.Job queue: {14, 12}Current job: 14Job unfinished. Return to the rear of the queue.Job queue: {12, 4}Current job: 12Job unfinished. Return to the rear of the queue.Job queue: {4, 2}Current job: 4Job finishedJob queue: {2}Current job: 2Job finishedJob queue: {}CLASS:LISTQUEUEclass ListQueue(object): “””An list-based stack implementation.””” # Constructor def __init__(self, sourceCollection = None): “””Sets the initial state of self, which includes the contents of sourceCollection, if it’s present.””” self.items = [] if sourceCollection is not None: for item in sourceCollection: self.items.append(item) pass # Accessor methods def isEmpty(self): “””Returns True if the queue is empty, or False otherwise.””” if len(self) == 0: return True else: False pass def __len__(self): “””Returns the number of items in the queue.””” return len(self.items) pass def __str__(self): “””Returns the string representation of the queue.””” return “{” + “,”.join(map(str, self.items)) + “}” pass def __iter__(self): “””Supports iteration over a view of the queue.””” cursor = 0 while cursor < len(self): yield self.items[cursor] cursor+=1 pass def __add__(self, other): """Returns a new queue containing the contents of self and other.""" result = ListQueue() for item in self: result.add(item) for item in other: result.add(item) return result pass def __eq__(self, other): """Returns True if self equals other, or False otherwise.""" if len(self) == len(other): # go through each item of self collection for item in self.items: # if item not in other collection, then return False if item not in other.items: return False return True return False pass def peek(self): """Returns the item at the front of the queue. Precondition: the queue is not empty. Raises IndexError if queue is not empty.""" if len(self) == 0: return IndexError return self.items[0] pass # Mutator methods def clear(self): """Makes self become empty.""" self.items = [] pass def add(self, item): """Inserts item at rear of the queue.""" self.items.append(item) pass def pop(self): """Removes and returns the item at the front of the queue. Precondition: the queue is not empty. Raises IndexError if queue is not empty. Postcondition: the front item is removed from the queue.""" if len(self)==0: return IndexError oldItem = self.items[len(self)-1] self.items.remove(oldItem) return oldItem passSTARTER CODE FOR ROUND ROBIN:from listqueue import ListQueuedef round_robin(job_queue): """ Each job in the job queue has a time slice of 10 time units. An unfinished job will be returned to the rear of the queue. """ passdef test_round_robin(): job_list = [17, 5, 32, 8, 24] job_queue = ListQueue(job_list) print("Initial job queue:", job_queue) round_robin(job_queue)test_round_robin()Computer ScienceEngineering & TechnologyPython Programming CSC 130
solved : Round-Robin CPU scheduling is described. ((Write_) a…
How it works
- Paste your instructions in the instructions box. You can also attach an instructions file
- Select the writer category, deadline, education level and review the instructionsÂ
- Make a payment for the order to be assigned to a writer
- Â Download the paper after the writer uploads itÂ
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
LET THE PROFESSIONALS WRITE YOUR PAPER!