-
大小: 16KB文件類(lèi)型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-06-04
- 語(yǔ)言: C/C++
- 標(biāo)簽: 操作系統(tǒng)??模擬實(shí)現(xiàn)??C/C++??
資源簡(jiǎn)介
本資源用c++模擬操作系統(tǒng)的實(shí)現(xiàn)
主要內(nèi)容:1.進(jìn)程控制 2.分頁(yè)式存儲(chǔ)管理 3.設(shè)備管理4.文件管理 5.進(jìn)程調(diào)度
有問(wèn)題 聯(lián)系 lx15636825085@163.com

代碼片段和文件信息
#include?
#include?“stdlib.h“
#include?“conio.h“
using?namespace?std;
/*定義結(jié)構(gòu)體*/
typedef?struct?PCB
{
??char?name[20];
??struct?PCB?*?next;
}PCB;
PCB?*ready*blocked*running*finished;
void?add(PCB?*head?PCB?*process)?{
????PCB?*tmp?=?head;
while(tmp->next?!=?NULL)
????tmp?=?tmp->next;
tmp->next?=?process;
process->next?=?NULL;
}
PCB?*?out(PCB?*head)?{
????PCB?*p;
p?=?head;
if(p->next?==?NULL)
return?NULL;
else
{
p?=?p->next;
head->next?=?p->next;
p->next?=?NULL;
return?p;
}
}
void?create()?{
????PCB?*p;
p?=?(PCB*)malloc(sizeof(PCB));
p->next?=?NULL;
cout<<“請(qǐng)輸入PCB的名稱(chēng):“;
cin>>p->name;
add(ready??p);
if(running->next?==?NULL?&&?p?!=?NULL)?{
p=out(ready);
add(running??p);
}
}
void?torun()?{
PCB?*p;
p?=?out(ready);
if(running->next?!=?NULL?&&?p?!=?NULL?)
????????add(running??p);
}
void?timeout()?{
PCB?*p;
p?=?out(running);
if(p?!=?NULL)
????add(ready??p);
p?=?out(ready);
if(running->next?==?NULL?&&?p?!=?NULL)?
add(running??p);
}
void?wakeup()?{
PCB?*p;
p?=?out(blocked);
if(p?!=?NULL)
????add(ready??p);
}
void?block()?{
PCB?*p;
p?=?out(running);
if(p?!=?NULL)
????add(blocked??p);
p?=?out(ready);
if(running->next?==?NULL?&&?p?!=?NULL)?
add(running??p);
}
void?ending()?{
PCB?*p;
p?=?out(running);
if(p?!=?NULL)
????add(finished??p);
p?=?out(ready);
if(running->next?==?NULL?&&?p?!=?NULL)?
add(running??p);
}
void?show()?{
????PCB?*p;
p?=?ready->next;
????cout<<“ready:?“;
while(p?!=?NULL)?{
????????cout<name<<“?“?;
????p=p->next;
}
????cout<
p?=?running->next;
????cout<<“running:?“;
while(p?!=?NULL)?{
????????cout<name<<“?“?;
????p=p->next;
}
cout<
p?=?blocked->next;
????cout<<“blocked:?“;
while(p?!=?NULL)?{
????????cout<name<<“?“?;
????p=p->next;
}
cout<
p?=?finished->next;
????cout<<“finished:?“;
while(p?!=?NULL)?{
????????cout<name<<“?“?;
????p=p->next;
}
cout< }
void?help()?{
cout<<“_____________________HELP?MENU_____________________“< cout<<“?h——HELP?show?help?optionn“< cout<<“?c——CREATE?create?a?new?process??and?put?to?ready?queuen“< cout<<“?b——BLOCK?block?a?process?in?excute?queuen“< cout<<“?w——WAKEUP?a?process?in?wait?queuen“< cout<<“?r——RUN?run?excute?a?process?in?ready?queuen“< cout<<“?s——SHOW?show?the?PCB?all?state“< cout<<“?e——ENDING?end?a?procee?in?running“< cout<<“?t——TIMEOUT?let?a?process?to?run“< ????cout<<“?q——QUIT?quit?the?PCB“< cout<<“_____________________________________________________“< }
void?init(){
ready?=?(PCB*)malloc(sizeof(PCB));
????ready?->?next=NULL;
????running?=?(PCB*)malloc(sizeof(PCB));
????running?->?next=NULL;
????blocked=?(PCB*)malloc(sizeof(PCB));
????blocked?->?next?=?NULL;
????finished?=(PCB*)malloc(sizeof(PCB));
fini
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)一\
?????文件????????3813??2017-09-19?21:43??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)一\OS1.cpp
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)三\
?????文件???????20165??2017-11-25?00:38??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)三\OS3.cpp
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)二\
?????文件????????6087??2017-10-10?20:22??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)二\OS2_1.cpp
?????文件???????13986??2017-10-29?23:11??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)二\OS2_2.cpp
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)五\
?????文件???????14047??2017-11-25?00:34??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)五\OS5.CPP
?????目錄???????????0??2018-04-14?10:50??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)四\
?????文件???????10979??2017-11-23?21:42??操作系統(tǒng)OS實(shí)驗(yàn)\實(shí)驗(yàn)四\OS4.CPP
評(píng)論
共有 條評(píng)論