RR算法python代码
时间: 2023-03-30 20:02:22 浏览: 154
rr.rar_RR_python
以下是RR算法的Python代码:
```python
def round_robin(processes, quantum):
n = len(processes)
waiting_time = [] * n
turnaround_time = [] * n
remaining_time = [p[1] for p in processes]
current_time =
while True:
done = True
for i in range(n):
if remaining_time[i] > :
done = False
if remaining_time[i] > quantum:
current_time += quantum
remaining_time[i] -= quantum
else:
current_time += remaining_time[i]
turnaround_time[i] = current_time - processes[i][]
waiting_time[i] = turnaround_time[i] - processes[i][1]
remaining_time[i] =
if done:
break
return waiting_time, turnaround_time
```
希望对你有帮助!
阅读全文