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

  • 大小: 3KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-24
  • 語言: C/C++
  • 標簽: 模擬進程??

資源簡介

內容:設計一個簡單的進程調度算法,模擬OS中的進程調度過程 2.要求: ① 進程數不少于5個; ② 進程調度算法任選; 最好選用動態優先數法,每運行一個時間片優先數減3 ③ 用C++(或C)語言編程; ④ 程序運行時顯示進程調度過程。 3.步驟: ① 設計PCB及其數據結構: 進程標識數:ID 進程優先數:PRIORITY(優先數越大,優先級越高) 進程已占用時間片:CPUTIME 進程尚需時間片:ALLTIME(一旦運行完畢,ALLTIME為0) 進程隊列指針:NEXT,用來將PCB排成隊列 進程狀態:STATE(一般為就緒,不用) ② 設計進程就緒隊列及數據結構; ③ 設計進程調度算法,并畫出程序流程圖; ④ 設計輸入數據和輸出格式; 結構格式:當前正運行的進程:0 當前就緒隊列:2,1,3,4 ⑤ 編程上機,驗證結果。

資源截圖

代碼片段和文件信息

#include
#include
#include
#include

#define?LEN?sizeof(struct?PROCESS)

typedef?struct?PROCESS
{
char?ID[10];
unsigned??int?PRIORITY;
unsigned??int?CPUTIME;
unsigned??int?ALLTIME;
char?STATE;
struct?PROCESS?*?NEXT;
}PRO;
PRO?*?ready=NULL;

PRO?*?Creatnode()
{
PRO?*?p=NULL;
p=(PRO?*)malloc(LEN);
//system(“cls“);
printf(“請輸入進程名:\n“);
scanf(“%s“&p->ID);
printf(“請輸入優先級數:\n“);
scanf(“%d“&p->PRIORITY);
printf(“請輸入以運行時間:\n“);
scanf(“%d“&p->CPUTIME);
printf(“請輸入剩余時間:\n“);
scanf(“%d“&p->ALLTIME);
p->STATE=‘P‘;
p->NEXT=NULL;
return?p;
}
void?Insert1(PRO?*?node)
{
PRO?*?p=ready;
PRO?*?q=NULL;
if(ready==NULL)
{
ready=node;
ready->NEXT=NULL;
return?;
}
if(node->PRIORITY>ready->PRIORITY)
{
node->NEXT=ready;
ready=node;
return?;
}
while(p->NEXT!=NULL)
{
q=p;
p=p->NEXT;
if(node->PRIORITY?>?p->PRIORITY)
{
q->NEXT=node;
node->NEXT=p;
return;
}
}
if((p->NEXT==NULL)&&?(node->PRIORITYPRIORITY))
{
p->NEXT=node;
return;
}
}

void?Insert()
{
PRO?*?p=NULL;
PRO?*?q=NULL;
char?ch=‘\0‘;
ch=getchar();
while(ch!=‘n‘)
{
if(ready==NULL)
{
p=Creatnode();
ready=p;
}
else
{
p=Creatnode();
Insert1(p);
}
printf(“繼續添加進程?y?or?Y\n結束添加?n?or?N\n“);
getchar();
ch=getchar();
}
}
PRO?*?Getnode()
{
PRO?*?p=ready;
if(p==NULL)
{
printf

評論

共有 條評論