Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from openpyxl import load_workbook
- wb = load_workbook(filename="cpu-scheduling.xlsx")
- sheet = wb.active
- wt = [] #waiting time list
- collected = [[], [], [], []]
- def fifo():
- for active in sheet.iter_rows():
- if isinstance(active[0].value, str):
- continue
- collected[0].append(active[0].value)
- collected[1].append(active[1].value)
- collected[2].append(active[2].value)
- collected[3].append(active[3].value)
- # These lines get the data from the excel and places them in their own list
- # Find waiting time
- def WaitingTime(bursttime, arrival_index):
- waiting_time = bursttime + arrival_index
- return waiting_time
- # Find Turnaroundtime
- def tat(bursttime):
- tat = bursttime + WaitingTime()
- return tat
- time_unit = 0
- for pid, bt in zip(collected[0], collected[2]):
- for btl in range(bt, 0, -1):
- if btl > 1:
- print(f"Time unit: {time_unit}, PID {pid} executing, remaining burst time: {btl}")
- else:
- print(f"Time unit: {time_unit}, context switch")
- time_unit += 1
- for verdi in sheet.iter_rows():
- for row in sheet.iter_rows():
- temp = []
- for x in range(len(verdi)):
- temp.append(verdi[1].value)
- collected.append(temp)
- if __name__ == "__main__":
- fifo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement