First Come First Serve Process scheduling using python

process = []
total_waiting_time = 0
n = int(raw_input('Enter the total no of processes: '))
for i in xrange(n):
    process.append([])
    process[i].append(raw_input('Enter process name: '))
    process[i].append(int(raw_input('Enter process arrival time : ')))
    total_waiting_time += process[i][1]
    process[i].append(int(raw_input('Enter process  burst time: ')))
    print ''

process.sort(key = lambda process:process[1])

print 'Process Name\tArrival Time\tBurst Time'
for i in xrange(n):
    print process[i][0],'\t\t',process[i][1],'\t\t',process[i][2]
   
print 'Total waiting time: ',  total_waiting_time
print 'Average waiting time: ',(total_waiting_time/n)

No comments: