資源簡介
緩沖池 操作系統課設 實現了一個循環緩沖隊列,讀線程從緩沖隊列中讀取數據,寫線程向緩沖隊列放入數據。可以運用在在網絡文件傳輸或者本地文件復制。
代碼片段和文件信息
#include?
#include?“f:\bufferpool\Queue.h“
using?namespace?std;
using?std::cin;
using?std::cout;
using?std::string;
using?std::endl;
int?main()
{int?ijbuffer;
SqQueue?QQ1Q2;
????int?Input(SqQueue?&QSqQueue?&Q1);
????int?Inget(SqQueue?&QSqQueue?&Q1);
????int?Output(SqQueue?&QSqQueue?&Q2);
????int?Outget(SqQueue?&QSqQueue?&Q2);
????InitQueue(Q);???//創建空緩沖隊列
????InitQueue(Q1);??//創建輸入隊列
????InitQueue(Q2);??//創建輸出隊列
????cout<<“請輸入緩沖區空位的總數目:“;
???cin>>buffer;
???cout<<“緩沖區共有“< ????for(j=0;j ????cout?<“請輸入所選進程的代號:“< ????while(1)
{
cout<<“????????????1:收容輸入??????????“?<cout<<“????????????2:提取輸入??????????“?<cout<<“????????????3:收容輸出??????????“?<cout<<“????????????4:提取輸入??????????“?<cout<<“????????????5:退出???????????????“?<cin>>i;
switch(i)
{
case?1:Input(QQ1);?break;//功能選項
case?2:Inget(QQ1);?break;
case?3:Output(QQ2);?break;
case?4:Outget(QQ2);?break;
case?5:return?0;
}
}
????return?0;
}
int?Input(SqQueue?&QSqQueue?&Q1)
{int?e;
????if(QueuLength(Q)>0)?{?cout<<“正在執行收容輸入操作“< ????????????????????e=DeQueue(Qe);EnQueue(Q1e);
????????????????????cout<<“緩沖池中有“< ????????????????????cout<<“輸入隊列中有“< ????if(QueuLength(Q)==0)?cout<<“緩沖池中的數據已空,不能再收容數據“< }
int?Inget(SqQueue?&QSqQueue?&Q1)
{int?e;
????if(QueuLength(Q1)>0){cout<<“正在執行提取輸入操作“< ????????????????e=DeQueue(Q1e);EnQueue(Qe);
????????????????cout<<“緩沖池中有“< ????????????????cout<<“輸入隊列中有“< ????if(QueuLength(Q1)==0)?cout<<“輸入隊列中的數據已空,不能再提取數據“< }
int?Output(SqQueue?&QSqQueue?&Q2)
{int?e;
????if(QueuLength(Q)>0)?{?cout<<“正在執行收容輸出操作“< ????????????????????e=DeQueue(Qe);EnQueue(Q2e);
????????????????????cout<<“緩沖池中有“< ????????????????????cout<<“輸出隊列中有“< ????if(QueuLength(Q)==0)?cout<<“緩沖池中的數據已空,不能再收容數據“< }
int?Outget(SqQueue?&QSqQueue?&Q2)
{int?e;
????if(QueuLength(Q2)>0){cout<<“正在執行提取輸出操作“< ????????????????e=DeQueue(Q2e);EnQueue(Qe);
????????????????cout<<“緩沖池中有“< ????????????????cout<<“輸出隊列中有“< ????if(QueuLength(Q2)==0)?cout<<“輸出隊列中的數據已空,不能再提取數據“< }
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????608683??2010-12-31?17:10??bufferpool\bin\Debug\system.exe
?????文件?????????44??2009-11-26?10:04??bufferpool\ElemType.h
?????文件???????2677??2010-12-31?17:09??bufferpool\main.cpp
?????文件?????121416??2010-12-31?17:10??bufferpool\obj\Debug\main.o
?????文件???????7036??2010-12-31?17:10??bufferpool\obj\Debug\Queue.o
?????文件????????723??2010-12-31?17:10??bufferpool\Queue.cpp
?????文件????????349??2010-12-31?17:10??bufferpool\Queue.h
?????文件???????1198??2010-05-25?09:55??bufferpool\system.cbp
?????文件???????1534??2010-12-07?16:10??bufferpool\system.depend
?????文件????????542??2010-12-07?16:11??bufferpool\system.layout
?????文件????????206??2010-12-28?15:53??bufferpool\system.workspace
?????目錄??????????0??2010-12-07?16:11??bufferpool\bin\Debug
?????目錄??????????0??2010-12-07?16:11??bufferpool\obj\Debug
?????目錄??????????0??2010-12-07?16:11??bufferpool\bin
?????目錄??????????0??2010-12-07?16:11??bufferpool\obj
?????目錄??????????0??2010-12-07?16:11??bufferpool
-----------?---------??----------?-----??----
???????????????744408????????????????????16
- 上一篇:EDULINE在線教育系統
- 下一篇:linux安全加固
評論
共有 條評論