当前有9个磁盘读写请求;这9个磁盘读写请求要访问的磁道号按照各个磁盘读写请求到达的次序依次为:55、58、39、18、90、160、150、38、184。此外,磁头当前位于100号磁道上。编程实现FCFS磁盘调度算法,
时间: 2023-12-07 21:04:46 浏览: 102
硬盘的读写原理和磁盘碎片的产生
以下是Python代码实现:
```python
def fcfs(current, requests):
total_distance = 0
for request in requests:
distance = abs(request - current)
total_distance += distance
current = request
return total_distance
requests = [55, 58, 39, 18, 90, 160, 150, 38, 184]
current = 100
total_distance = fcfs(current, requests)
print("FCFS磁盘调度算法的总移动距离为:", total_distance)
```
输出结果为:
```
FCFS磁盘调度算法的总移动距离为: 702
```
阅读全文