Question: 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

convert this python to c class Task: def __init__(self, name, priority, burst_time):

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!