南昌大学操作系统实验报告.pdfVIP

  • 1
  • 0
  • 约9.22千字
  • 约 11页
  • 2020-07-22 发布于江苏
  • 举报
南昌大学实验报告 (3 )进 程 调 度 算 法 的 实 现 学生姓名:张皓然学号: 5501215001 专业班级:本硕 151 实验类型:□ 验证 □ 综合 ■ 设计□ 创新 实验日期: 2017.5.31 实验成绩: 一、实验目的 通过实验加强对进程调度算法的理解和掌握。 二、实验内容 编写程序实现进程调度算法, 具体可以编写程序实现优先度高者调度算法或先来先服务 算法。 三、实验要求 1、需写出设计说明; 2、设计实现代码及说明 3、运行结果; 四、主要实验步骤 1 优先度高者调度算法实验代码: ○ #include stdio.h #include stdlib.h #include time.h #include malloc.h #include string.h #define runtime 2 #define overflow -2 #define null 0 enum sta { run, wait, finished }; // 枚举类型 sta ,标志三种状态 time_t t; //system clock struct block { int time_used; int prior; }; // 定义结构体,使用时间,优先级 typedef struct pro { char name[20]; enum sta status; int time_required; int arrive_time; struct block switch_block; struct pro *next; }*pcb;// 定义 pcb 块 pcb ready; void menu(); void insertpcb(pcb newp) // 插入至就绪队列 { pcb p; p = (pcb)malloc(sizeof(struct pro)); if (!p)exit(overflow); p = ready; if (p-next == null) { newp-next = ready-next; ready-next = newp; } else { while (newp-switch_block.priorp-next-switch_block.priorp-next != null) p = p-next; newp-next = p-next; p-next = newp; } } void creat_pcb() // 创建一个进程 { pcb newp; newp = (pcb)malloc(sizeof(struct pro)); if (!newp) exit(overflow); newp-status = wait; time(t); newp-arrive_time = t; printf(process name:); scanf(%s, newp-name); printf(priority:); scanf(%d, newp-switch_block.prior); printf(arrive time:); scanf(%d, newp-arrive_time); printf(cputime_required:); scanf(%d, newp-time_required); newp-switch_block.time_used = 0; ins

文档评论(0)

1亿VIP精品文档

相关文档