欧美一区2区三区4区公司二百,国产精品婷婷午夜在线观看,自拍偷拍亚洲精品,国产美女诱惑一区二区

c語(yǔ)言之SJF

#include <malloc.h>
#include <stdio.h>
?
typedef struct table
{
? ? char name[10];//進(jìn)程名
? ? int id;//進(jìn)程id
? ? int atime;//到達(dá)時(shí)間
? ? int stime;//開(kāi)始時(shí)間
? ? int runtime;//運(yùn)行時(shí)間
? ? int ftime;//完成時(shí)間
? ? float total;//周轉(zhuǎn)時(shí)間
? ? float weight;//帶權(quán)周轉(zhuǎn)時(shí)間
? ? int starttime;
? ? int finishtime;
}PCB;
?
typedef struct _Node
{
? ? struct _Node* next;
? ? PCB pcb;
}node;
?
struct node* creat(int count)
{
? ? node* head = malloc(sizeof(node));
? ? head->next = NULL;
? ? node* move = head;
?
? ? for (int i = 0; i < count; i++)
? ? {
? ? ? ? node* fresh = malloc(sizeof(node));
? ? ? ? fresh->next = NULL;
? ? ? ? move->next = fresh;
?
? ? ? ? printf("請(qǐng)輸入第%d個(gè)進(jìn)程的id、到達(dá)時(shí)間、運(yùn)行時(shí)間:\n", i + 1);
? ? ? ? scanf("%d%s%d%d", &fresh->pcb.id, fresh->pcb.name, &fresh->pcb.atime, &fresh->pcb.runtime);
?
? ? ? ? move = fresh;
? ? }
? ? return head;
}
?
void fcfs(node* head) {
? ? for (node* turn = head->next; turn->next != NULL; turn = turn->next)
? ? {
? ? ? ? for (node* move = head->next; move->next != NULL; move = move->next)
? ? ? ? {
? ? ? ? ? ? if (move->pcb.atime > move->next->pcb.atime)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? PCB temp = move->pcb;
? ? ? ? ? ? ? ? move->pcb = move->next->pcb;
? ? ? ? ? ? ? ? move->next->pcb = temp;
? ? ? ? ? ? }
?
? ? ? ? }
?
? ? }
}
?
void middle(node* head) {
? ? for (node* turn = head->next; turn->next != NULL; turn = turn->next)
? ? {
? ? ? ? for (node* move = head->next; move->next != NULL; move = move->next)
? ? ? ? {
? ? ? ? ? ? if (move->pcb.atime == move->next->pcb.atime && move->pcb.runtime > move->next->pcb.runtime) {
? ? ? ? ? ? ? ? PCB temp = move->pcb;
? ? ? ? ? ? ? ? move->pcb = move->next->pcb;
? ? ? ? ? ? ? ? move->next->pcb = temp;
? ? ? ? ? ? }
?
? ? ? ? }
? ? }
}
?
void sjf(node* head) {
? ? node* temp = head->next;
? ? node* move = head->next->next;
? ? temp->pcb.starttime = temp->pcb.atime;
? ? temp->pcb.finishtime = temp->pcb.starttime + temp->pcb.runtime;
? ? int num = temp->pcb.finishtime;
? ? while (move->next != NULL) {
? ? ? ? temp = temp->next;
? ? ? ? move = move->next;
? ? ? ? node* tap = move;
? ? ? ? while (move != NULL) {
? ? ? ? ? ? if (temp->pcb.atime <= num && move->pcb.atime <= num && temp->pcb.runtime > move->pcb.runtime) {
? ? ? ? ? ? ? ? PCB map = temp->pcb;
? ? ? ? ? ? ? ? temp->pcb = move->pcb;
? ? ? ? ? ? ? ? move->pcb = map;
? ? ? ? ? ? ? ? move = move->next;
? ? ? ? ? ? }
? ? ? ? ? ? else {
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? if (temp->pcb.atime < num) {
? ? ? ? ? ? num = num + temp->pcb.runtime;
?
? ? ? ? }
? ? ? ? else {
? ? ? ? ? ? num = temp->pcb.atime + temp->pcb.runtime;
?
? ? ? ? }
? ? ? ? move = tap;
? ? }
}
?
?
void running(node* head) {
? ? node* move = head->next;
? ? while (move != NULL) {
? ? ? ? printf("%s程序正在運(yùn)行.....\n", move->pcb.name);
? ? ? ? move = move->next;
? ? }
}
?
void s_f_t_w_time(node* head) {
? ? node* move = head->next->next;
? ? node* first = head->next;
? ? first->pcb.total = first->pcb.runtime;
? ? first->pcb.stime = first->pcb.atime;
? ? first->pcb.ftime = first->pcb.stime + first->pcb.runtime;
? ? first->pcb.weight = first->pcb.total / first->pcb.runtime;
? ? printf("%d %4s %7d %11d %10d %10d %16f %10f\n", first->pcb.id, first->pcb.name, first->pcb.atime, first->pcb.runtime, first->pcb.stime, first->pcb.ftime, first->pcb.total, first->pcb.weight);
? ? while (move != NULL) {
? ? ? ? if (first->next->pcb.atime <= first->pcb.ftime) {
? ? ? ? ? ? first->next->pcb.stime = first->pcb.ftime;
? ? ? ? ? ? first->next->pcb.ftime = first->next->pcb.stime + first->next->pcb.runtime;
? ? ? ? ? ? first->next->pcb.total = first->next->pcb.stime + first->next->pcb.runtime - first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.weight = first->next->pcb.total / first->next->pcb.runtime;
? ? ? ? }
? ? ? ? else {
? ? ? ? ? ? first->next->pcb.stime = first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.ftime = first->next->pcb.stime + first->next->pcb.runtime;
? ? ? ? ? ? first->next->pcb.total = first->next->pcb.stime + first->next->pcb.runtime - first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.weight = first->next->pcb.total / first->next->pcb.runtime;
? ? ? ? }
? ? ? ? printf("%d %4s %7d %11d %10d %10d %16f %10f\n", first->next->pcb.id, first->next->pcb.name, first->next->pcb.atime, first->next->pcb.runtime, first->next->pcb.stime, first->next->pcb.ftime, first->next->pcb.total, first->next->pcb.weight);
? ? ? ? first = first->next;
? ? ? ? move = move->next;
? ? }
}
?
int main(void) {
? ? node* p;
? ? printf("請(qǐng)輸入進(jìn)程數(shù)量:\n");
? ? int count;
? ? scanf("%d", &count);
? ? p = creat(count);
? ? fcfs(p);
? ? middle(p);
? ? sjf(p);
? ? running(p);
? ? printf(" id ? ?進(jìn)程名 ? 到達(dá)時(shí)間 ? 運(yùn)行時(shí)間 ? 開(kāi)始時(shí)間 ? 結(jié)束時(shí)間 ? 周轉(zhuǎn)時(shí)間 ? 帶權(quán)周轉(zhuǎn)時(shí)間\n");
? ? s_f_t_w_time(p);
?
}

c語(yǔ)言之SJF

文章鏈接: http://www.qzkangyuan.com/27156.html

文章標(biāo)題:c語(yǔ)言之SJF

文章版權(quán):夢(mèng)飛科技所發(fā)布的內(nèi)容,部分為原創(chuàng)文章,轉(zhuǎn)載請(qǐng)注明來(lái)源,網(wǎng)絡(luò)轉(zhuǎn)載文章如有侵權(quán)請(qǐng)聯(lián)系我們!

聲明:本站所有文章,如無(wú)特殊說(shuō)明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個(gè)人或組織,在未征得本站同意時(shí),禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書(shū)籍等各類(lèi)媒體平臺(tái)。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。

給TA打賞
共{{data.count}}人
人已打賞
建站教程投稿分享

c語(yǔ)言之fcfs

2024-1-29 13:08:26

投稿分享

SQLServer2000同步復(fù)制技術(shù)實(shí)現(xiàn)操作步驟

2024-1-30 17:11:21

0 條回復(fù) A文章作者 M管理員
    暫無(wú)討論,說(shuō)說(shuō)你的看法吧
?
個(gè)人中心
購(gòu)物車(chē)
優(yōu)惠劵
今日簽到
有新私信 私信列表
搜索
主站蜘蛛池模板: 玉树县| 固阳县| 长阳| 会昌县| 宁蒗| 大庆市| 遂溪县| 夹江县| 乡宁县| 澳门| 乌审旗| 安阳市| 盘山县| 邯郸县| 曲麻莱县| 建始县| 杭锦后旗| 蒲城县| 新宁县| 焉耆| 房山区| 杭锦旗| 长丰县| 连州市| 临泽县| 灯塔市| 仪征市| 庐江县| 临清市| 英山县| 蕲春县| 饶平县| 平江县| 海盐县| 封丘县| 浙江省| 巍山| 芒康县| 武穴市| 根河市| 清新县|