(一)进程调度的相关算法
来源:互联网 发布:网络营销策划案模板 编辑:程序博客网 时间:2024/05/16 14:49
进程调度
进程调度的算法有FIFO、优先数调度算法(静态优先级)、时间片轮转调度算法、分级调度算法;其中FIFO和优先数调度算法在试题中出现的频率较高。
输入
进程流文件,其中存储的是一系列要执行的进程,每个作业包括四个数据项:
- 进程名
- 进程状态(就绪、等待、运行)
- 所需时间
- 优先级数(0级最高)。
输出
进程执行流、等待时间、平均等待时间。
部分代码
优先数调度算法
void privilege(){<span style="white-space:pre"></span>int i,j,p;<span style="white-space:pre"></span>int passed_time=0;<span style="white-space:pre"></span>int total;<span style="white-space:pre"></span>int queue[MAXPCB];<span style="white-space:pre"></span>int current_privilege=1000;<span style="white-space:pre"></span>for(i=0;i<quantity;i++)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>current_privilege=1000;<span style="white-space:pre"></span>for(j=0;j<quantity;j++)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>if((pcbs[j].finished==0)&&(pcbs[j].privilege<current_privilege))<span style="white-space:pre"></span>{<span style="white-space:pre"></span>p=j;<span style="white-space:pre"></span>current_privilege=pcbs[j].privilege;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>}<span style="white-space:pre"></span>queue[i]=p;<span style="white-space:pre"></span>pcbs[p].finished=1;<span style="white-space:pre"></span>pcbs[p].wait_time+=passed_time;<span style="white-space:pre"></span>passed_time+=pcbs[p].time;<span style="white-space:pre"></span>}<span style="white-space:pre"></span><span style="white-space:pre">//输出优先数调度执行流 cout<<endl<<"------------------------"<<endl; cout<<"优先数调度执行流:"<<endl; cout<<"进程名 等待时间"<<endl; for(i=0;i<quantity;i++)</span><span style="white-space:pre">{ out<<" "<<pcbs[queue[i]].name<<" "<<pcbs[queue[i]].wait_time<<endl; } <<</span><span style="white-space:pre"></span>total=0;<span style="white-space:pre"></span>for(i=0;i<quantity;i++)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>total+=pcbs[i].wait_time;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>coun<<"总等待时间:"<<total<<"平均等待时间:"<<total/quantity<<end1;}
0 0
- (一)进程调度的相关算法
- 实验一 进程调度算法
- 进程的调度算法
- 进程的调度算法
- 进程的调度算法
- 进程的调度算法
- 进程的调度算法
- 进程的调度算法
- 进程调度算法(进程调度策略)
- 进程调度(一)
- 【亚嵌】Linux进程调度算法分析(一)
- 进程调度(一)——FIFO算法
- 进程的调度方式,调度算法总结
- 进程调度算法的设计
- OS的进程调度算法
- 常见的进程调度算法
- 常见的进程调度算法
- 常见进程的调度算法
- NodeJS实战
- 线程池的原理及实现
- Java基础知识
- Exynos4412 中断驱动开发(一)—— 中断基础及中断的注册过程
- 模拟迅雷下载程序 多线程
- (一)进程调度的相关算法
- ssh socket转发代理
- AE C# 图片标注背景透明
- 个人所得税计算器
- poj2352线段树
- 数据结构和算法笔记
- Educational Codeforces Round 9
- Coincidence
- 快速排序