好文档 - 专业文书写作范文服务资料分享网站

实验二FPF和RR调度算法 - 图文 

天下 分享 时间: 加入收藏 我要投稿 点赞

while (cp != NULL) {

if (r->p_priority > cp->p_priority) break; else {

ap = cp; cp = cp->next; } }

if (ap == NULL) {

r->next = SL; SL = r; } else {

r->next = cp; ap->next = r; } r = t; }

return SL; }

测试数据:

进程名:1 3 6 8 4 进程优先数:2 4 3 52 3 进程运行时间:5 5 7 6 4 运行结果如下图:

RR调度算法: #include #include #include using namespace std; #define MAXSIZE 5

int ID[MAXSIZE], COME_TIME[MAXSIZE], RUN_TIME[MAXSIZE]; struct processing {

int pid;

//作业号

int sequence; //顺序号 double come_time; //到达时 double run_time; //运行时 double last_run_time;

//剩余运行时间

double over_time; //完成时 double round_time; //周转时 double avg_time; //带权周转时

//作业数

}pc[MAXSIZE];

queue q;

bool CmpByComeTime(processing p1, processing p2) {

return p1.come_time

}

void push_in_queue() { }

void info_to_process() { }

void get_info() {

//输入进程信息

for (int i = 0; i

sort(pc, pc + MAXSIZE, CmpByComeTime); push_in_queue(); pc[i].sequence = i; pc[i].pid = ID[i];

pc[i].come_time = COME_TIME[i]; pc[i].run_time = RUN_TIME[i]; pc[i].last_run_time = pc[i].run_time;

//进程入队列

for (int i = 0; i < MAXSIZE; ++i) { }

q.push(pc[i]);

for (int i = 0; i

cin >> ID[i] >> COME_TIME[i] >> RUN_TIME[i];

}

info_to_process();

void print(double avg_sum_round_time, double avg_sum_avg_time) {

cout << \执行顺序:\for (int i = 0; i < MAXSIZE; ++i) { }

cout << endl;

cout << \作业号\到达时\运行时\/* code */

cout << pc[i].pid << \

完成时\周转时\带权周转时\ }

for (int ii = 0; ii < MAXSIZE; ++ii) { }

cout << \平均周转时: \

<< \平均带权周转时: \cout << pc[ii].pid << '\\t' << pc[ii].come_time << '\\t'

<< pc[ii].run_time << '\\t' << pc[ii].over_time << '\\t' << pc[ii].round_time << '\\t'<< pc[ii].avg_time << endl;

实验二FPF和RR调度算法 - 图文 

while(cp!=NULL){if(r->p_priority>cp->p_priority)break;else{ap=cp;cp
推荐度:
点击下载文档文档为doc格式
5udv64afxp1od1e2lms547le14lopx00wjx
领取福利

微信扫码领取福利

微信扫码分享