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 self.task_remaining_time = burst_time input_file_path

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 self.task_remaining_time = burst_time

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 = deque() # a deque 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_start_time = 0 # stores the starting time for the task while len(task_list) > 0: current_task = task_list.popleft() output_file.write( current_task.task_name + ", " + str(task_start_time) + ", " + str(current_task.task_burst_time) + " ")

# time quantum = 10 task_start_time = task_start_time + min(10, current_task.task_remaining_time) current_task.task_remaining_time = current_task.task_remaining_time - 10

# if still task has some execution time if current_task.task_remaining_time > 0: task_list.append(current_task)

1 # round robin algo for time quantum 10 2 from collections import deque # deque for queue implementation 3 4 # task object will store the task attributes 5 Eclass Task: 6 7 def _init__(self, name, priority, burst_time): 8 self.task_name = name 9 self.task_priority = priority 10 self.task_burst_time = burst_time 11 self.task_remaining_time = burst_time 12 13 14. input_file_path = input ("Please enter the path of the input file.") 15 output_file_path = input ("Please enter the path of the output file.") 16 17 Etry: input_file = open (input_file_path, "r") # opens the input file in read mode 19 Fexcept IOError: print("Error! Invalid input file path provided.") 21 exit(0) 22 23 output_file = open(output_file_path, "W") # opens the output file in write mode 24 27 28 29 31 32 25 task_list = deque () a deque that stores all tasks 26 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 30 task_list.append(Task (name, int (priority), int(burst_time)]) task_start_time = 0 + stores the starting time for the task 33 while len(task_list) > 0: current_task = task_list.popleft() output_file.write current_task.task_name + str(task_start_time) str (current_task.task_burst_time) + " ") # time quantum = 10 task_start_time = task_start_time + min (10, current_task.task_remaining_time) 40 current_task.task_remaining_Time = current_task.task_remaining_time - 10 # if still task has some execution time if current_task.task_remaining_time > 0: task_list.append(current_task) 34 35 e 36 37 38 39 41 42 43 44

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!