-
操作系统,包括最佳算法实验与进程控制
资源介绍
操作系统,最佳算法
部分代码 for (int i = 0; i != 5; ++i)
{
struct PCB *p = (struct PCB*)malloc(sizeof(struct PCB));
printf("进程号No.%d:\n", i);
printf("输入进程名:");
scanf("%s", p->p_name);
printf("输入进程运行时间:");
scanf("%d", &p->p_needTime);
p->p_runTime = 0;
p->p_state = 'W';
p->next = NULL;
pt->next = p;
pt = p;
printf("\n\n");
}
getchar(); //接受回车
//processes作为头结点来存储链表
processes = processes->next;
int cases = 0;
while (1)
{
++cases;
pt = processes;
printf("The execute number: %d\n\n", cases);
printf("**** 当前正在运行的进程是:%s\n", pt->p_name);
pt->p_state = 'R';
printf("qname state super ndtime runtime\n");
printf("%s\t%c\t%d\t%d\t%d\t\n\n", pt->p_name, pt->p_state, pt->p_priority, pt->p_needTime, pt->p_runTime);
pt->p_state = 'W';
pt->p_runTime++;
pt->p_priority--;
printf("**** 当前就绪状态的队列为:\n\n");
pt = pt->next;
while (pt != NULL)
{
- 上一篇: 操作系统课程设计Spooling输入输出模拟技术
- 下一篇: 实验室设备管理系统 c++ 课程设计