Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

convert this python to c class Task: def __init__(self, name, priority, burst_time): self.task_name = name self.task_priority = priority self.task_burst_time = burst_time # sorting function for

convert this python to c

image text in transcribed

class Task:

def __init__(self, name, priority, burst_time): self.task_name = name self.task_priority = priority self.task_burst_time = burst_time

# sorting function for task_list according to priority as in priority scheduling def sort_fun(task): return task.task_priority

input_file_path = input("Please enter the path of the input file.") output_file_path = input("Please enter the path of the output file.")

try: input_file = open(input_file_path, "r") # opens the input file in read mode except IOError: print("Error! Invalid input file path provided.") exit(0)

output_file = open(output_file_path, "w") # opens the output file in write mode

task_list = [] # a list that stores all tasks for each_entry in input_file: name, priority, burst_time = each_entry.split(", ")

# construct an object of class Task and append to the task_list task_list.append(Task(name, int(priority), int(burst_time)))

task_list.sort(key=sort_fun, reverse=True) # sort task_list according to priority in reverse order

task_start_time = 0 # stores the starting time for the task for each_task in task_list: output_file.write(each_task.task_name + ", " + str(task_start_time) + ", " + str(each_task.task_burst_time) + " ") task_start_time = task_start_time + each_task.task_burst_time

1 # priority scheduling (non premptive) 2 3 # task object will store the task attributes 4 Eclass Task: 5 6 def _init__(self, name, priority, burst_time) : 7 self.task_name = name self.task_priority = priority 9 self.task burst_time = burst time 10 11 12 # sorting function for task_list according to priority as in priority scheduling 13 def sort_fun(task) : return task.task_priority min 00 OOM 000 15 16 17 input_file_path = input ("Please enter the path of the input file.") 18 output_file_path = input ("Please enter the path of the output file.") 19 20 try: 21 L input_file = open(input_file_path, "r") # opens the input file in read mode 22 except IOError: 23 print("Error! Invalid input file path provided.") 24 exit(0) 25 26 output_file = open (output_file_path, "w") # opens the output file in write mode 28 29 30 31 32 33 34 35 36 task_list = 1 a list that stores all tasks for each_entry in input_file: name, priority, burst_time = each_entry.split(", ") #construct an object of class Task and append to the task_list task_list.append(Task (name, int (priority), int (burst_time))) task_list.sort (key=sort_fun, reverse=True) # sort task_list according to priority in reverse order task_start_time=0 + stores the starting time for the task for each_task in task_list: output_file.write (each_task.task_name + ", " + str (task_start_time) str (each_task.task_burst_time) + " ") task_start_time = task_start_time + each_task.task_burst_time 37 38 39 40 41

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago