这是操作系统课上的作业,SJF的那个调度要计算的实在太多就写了个程序帮我跑了。
题目如下:
**进程 到达时间 执行时间**
**P1 0 10**
** P2 1 8**
** P3 2 2**
** P4 3 4**
** P5 4 8**
**画****Gantt****图说明使用****FCFS****、非抢先式****SJF****、抢先式****SJF****、****RR****(时间片=****3****)调度算法进程调度情况。并分别求四种算法的平均周转时间,平均等待时间。平均权周转时间。**
用程序模拟了下实践过程
1 |
|
结果如下,有可能出现两种调度,具体怎样还不清楚是哪种
Time:0 P1 | Time:0 P1 |
Time:1 P1 | Time:1 P2 |
Time:2 P2 | Time:2 P1 |
Time:3 P3 | Time:3 P3 |
Time:4 P3 | Time:4 P3 |
Time:5 P4 | Time:5 P4 |
Time:6 P4 | Time:6 P4 |
Time:7 P4 | Time:7 P4 |
Time:8 P4 | Time:8 P4 |
Time:9 P2 | Time:9 P2 |
Time:10 P2 | Time:10 P2 |
Time:11 P2 | Time:11 P2 |
Time:12 P2 | Time:12 P2 |
Time:13 P2 | Time:13 P2 |
Time:14 P2 | Time:14 P2 |
Time:15 P2 | Time:15 P2 |
Time:16 P1 | Time:16 P1 |
Time:17 P1 | Time:17 P1 |
Time:18 P1 | Time:18 P1 |
Time:19 P1 | Time:19 P1 |
Time:20 P1 | Time:20 P1 |
Time:21 P1 | Time:21 P1 |
Time:22 P1 | Time:22 P1 |
Time:23 P1 | Time:23 P1 |
Time:24 P5 | Time:24 P5 |
Time:25 P5 | Time:25 P5 |
Time:26 P5 | Time:26 P5 |
Time:27 P5 | Time:27 P5 |
Time:28 P5 | Time:28 P5 |
Time:29 P5 | Time:29 P5 |
Time:30 P5 | Time:30 P5 |
Time:31 P5 | Time:31 P5 |
P1 wait_time: 14 | P1 wait_time: 14 |
P2 wait_time: 7 | P2 wait_time: 7 |
P3 wait_time: 1 | P3 wait_time: 1 |
P4 wait_time: 2 | P4 wait_time: 2 |
P5 wait_time: 20 | P5 wait_time: 20 |
P1 cycling_time: 24 | P1 cycling_time: 24 |
P2 cycling_time: 15 | P2 cycling_time: 15 |
P3 cycling_time: 3 | P3 cycling_time: 3 |
P4 cycling_time: 6 | P4 cycling_time: 6 |
P5 cycling_time: 28 | P5 cycling_time: 28 |