91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

操作系統課程實驗-利用C語言編寫的進程管理和進程調度任務。包括源程序和實驗報告。

資源截圖

代碼片段和文件信息

#include?“stdio.h“
#include??
#include??
#define?getpch(type)?(type*)malloc(sizeof(type))?
#define?NULL?0?
struct?pcb?{?/*?定義進程控制塊PCB?*/?
char?name[10];?
char?state;?
int?super;?
int?ntime;?
int?rtime;?
struct?pcb*?link;?
}*ready=NULL*p;?
typedef?struct?pcb?PCB;?
void?sort()?/*?建立對進程進行優先級排列函數*/?
{?
PCB?*first?*second;?
int?insert=0;?
if((ready==NULL)||((p->super)>(ready->super)))?/*優先級最大者插入隊首*/?
{?
p->link=ready;?
ready=p;?
}?
else?/*?進程比較優先級插入適當的位置中*/?
{?
first=ready;?
second=first->link;?
while(second!=NULL)?
{?
if((p->super)>(second->super))?/*若插入進程比當前進程優先數大*/?
{?/*插入到當前進程前面*/?
p->link=second;?
first->link=p;?
second=NULL;?
insert=1;?
}?
else?/*?插入進程優先數最低則插入到隊尾*/?
{?
first=first->link;?
second=second->link;?
}?
}?
if(insert==0)?first->link=p;?
}?
}??
void?input()?/*?建立進程控制塊函數*/?
{?
int?inum;?
printf(“\n?input?process?number?“);
scanf(“%d“&num);?
for(i=0;i{?
printf(“\n?input?the?process?No.%d:\n“i);
p=getpch(PCB);?
printf(“\n?the?name?of?Process:“);
scanf(“%s“p->name);?
printf(“\n?the?super?of?Process:“);
scanf(“%d“&p->super);?
printf(“\n?the?time?need:“);
scanf(“%d“&p->ntime);?
printf(“\n“);?
p->rtime=0;p->state=‘w‘;?
p->link=NULL;?
sort();?/*?調用sort函數*/?
}?
}?
int?space()?
{?
int?l=0;?PCB*?pr=ready;?
while(pr!=NULL)?
{?
l++;?
pr=pr->link;?
}?
return(l);?
}?
void?disp(PCB?*?pr)?/*建立進程顯示函數用于顯示當前進程*/?
{?
printf(“\n?qname?\t?state?\t?super?\t?ndtime?\t?runtime?\n“);?
printf(“|%s\t“pr->name);?
printf(“|%c\t“pr->state);?
printf(“|%d\t“pr->super);?
printf(“|%d\t“pr->ntime);?
printf(“|%d\t“pr->rtime);?
printf(“\n“);?
}???
void?check()?/*?建立進程查看函數?*/?
{?
PCB*?pr;?
printf(“\n?****?now?the?process?runing?is:%s“p->name);?/*顯示當前運行進程*/
disp(p);?
pr=ready;?
printf(“\n?****now?the?ready?quenue?is:\n“);?/*顯示就緒隊列狀態*/
while(pr!=NULL)?
{?
disp(pr);?
pr=pr->link;?
}?
}?
void?destroy()?/*建立進程撤消函數(進程運行結束撤消進程)*/?
{?
printf(“\n?process?[%s]?has?finished.\n“p->name);
free(p);?
}?
void?running()?/*?建立進程就緒函數(進程運行時間到置就緒狀態*/?
{?
(p->rtime)++;?
if(p->rtime==p->ntime)?
destroy();?/*?調用destroy函數*/?
else?
{?
(p->super)--;?
p->state=‘w‘;?
sort();?/*調用sort函數*/?
}?
}?
void?main()?/*主函數*/?
{?
int?lenh=0;?
char?ch;?
input();?
len=space();?
while((len!=0)&&(ready!=NULL))?
{?
ch=getchar();?
h++;?
printf(“\n?The?execute?number:%d?\n“h);?
p=ready;?
ready=p->link;?
p->link=NULL;?
p->state=‘R‘;?
check();?
running();?
printf(“\n?press?any?key?to?continue.“);
ch=getchar();?
}?
printf(“\n\n?process?is?over.\n“);
ch=getchar();?
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2808??2010-04-29?12:35??操作系統實驗\os02.c

?????文件?????653824??2011-12-28?18:05??操作系統實驗\操作系統實驗報告?梅蘢.doc

?????目錄??????????0??2010-04-29?12:35??操作系統實驗

-----------?---------??----------?-----??----

???????????????656632????????????????????3


評論

共有 條評論