os_kernel_lab/related_info/lab4/process-concept-homework.md

87 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2015-04-07 10:21:28 +08:00
设计一个简化的进程管理子系统,可以管理并调度如下简化进程.给出了参考代码
### 进程的状态
- RUNNING - 进程正在使用CPU
- READY - 进程可使用CPU
- DONE - 进程结束
### 进程的行为
- 使用CPU,
- 发出YIELD请求,放弃使用CPU
### 进程调度
- 使用FIFO/FCFS先来先服务
### 关键模拟变量
- 进程列表描述了进程的行为特征使用CPU ;(2)等待I/O
```
-l PROCESS_LIST, --processlist= X1:Y1,X2:Y2,...
X 是进程的执行指令数;
是执行CPU的比例(0..100) 如果是100表示不会发出yield操作
```
- 进程切换行为:系统决定何时(when)切换进程:进程结束或进程发出yield请求
### 进程执行
```
instruction_to_execute = self.proc_info[self.curr_proc][PROC_CODE].pop(0)
```
2015-04-07 10:21:28 +08:00
### 执行实例
#### 例1
```
$./process-simulation.py -l 5:50
Process 0
yld
yld
cpu
cpu
yld
Important behaviors:
System will switch when the current process is FINISHED or ISSUES AN YIELD
Time PID: 0
1 RUN:yld
2 RUN:yld
3 RUN:cpu
4 RUN:cpu
5 RUN:yld
```
#### 例2
```
$./process-simulation.py -l 5:50,5:50
Produce a trace of what would happen when you run these processes:
Process 0
yld
yld
cpu
cpu
yld
Process 1
cpu
yld
cpu
cpu
yld
Important behaviors:
System will switch when the current process is FINISHED or ISSUES AN YIELD
Time PID: 0 PID: 1
1 RUN:yld READY
2 READY RUN:cpu
3 READY RUN:yld
4 RUN:yld READY
5 READY RUN:cpu
6 READY RUN:cpu
7 READY RUN:yld
8 RUN:cpu READY
9 RUN:cpu READY
10 RUN:yld READY
11 RUNNING DONE
```