forked from Parassharmaa/operating-system-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcfs.py
More file actions
19 lines (16 loc) · 668 Bytes
/
fcfs.py
File metadata and controls
19 lines (16 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
process_queue = []
total_wtime = 0
n = int(input('Enter the total no of processes: '))
for i in range(n):
process_queue.append([])
process_queue[i].append(input('Enter p_name: '))
process_queue[i].append(int(input('Enter p_arrival: ')))
total_wtime += process_queue[i][1]
process_queue[i].append(int(input('Enter p_burst: ')))
print()
process_queue.sort(key = lambda process_queue:process_queue[1])
print('ProcessName\tArrivalTime\tBurstTime')
for i in range(n):
print(process_queue[i][0],'\t\t',process_queue[i][1],'\t\t',process_queue[i][2])
print('Total waiting time: ',total_wtime)
print('Average waiting time: ',(total_wtime/n))