没有合适的资源?快使用搜索试试~ 我知道了~
C++进程优先级调度进程优先级调度进程优先级调度
需积分: 42 16 下载量 201 浏览量
2009-11-06
15:09:34
上传
评论 1
收藏 36KB DOC 举报
温馨提示
试读
5页
C++进程优先级调度进程优先级调度进程优先级调度C++进程优先级调度进程优先级调度进程优先级调度
资源推荐
资源详情
资源评论
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node
{
char name[20]; /*进程的名字*/
int prio; /*进程的优先级*/
int round;
int needtime; /*进程执行所需要的时间*/
char state; /*进程的状态,W——就绪态,R——执行态,F——完成态*/
int count; /*记录执行的次数*/
struct node *next; /*链表指针*/
}PCB;
PCB *ready=NULL,*run=NULL,*finish=NULL; /*定义三个队列,就绪队列,执行队列和完
成队列*/
int num;
void GetFirst(); /*从就绪队列取得第一个节点*/
void Output(); /*输出队列信息*/
void InsertPrio(PCB *in); /*创建优先级队列,规定优先数越小,优先级越高*/
void InsertTime(PCB *in); /*时间片队列*/
void InsertFinish(PCB *in); /*时间片队列*/
void PrioCreate(); /*优先级输入函数*/
void Priority(); /*按照优先级调度*/
int main(void)
{
char chose;
printf("请输入要创建的进程数目:");
scanf("%d",&num);
getchar();
PrioCreate();
Priority();
Output();
return 0;
}
void GetFirst() /*取得第一个就绪队列节点*/
{
run = ready;
if(ready!=NULL)
{
run ->state = 'R';
ready = ready ->next;
run ->next = NULL;
}
}
资源评论
sdeptis
- 粉丝: 3
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功