模拟进程调度功能的设计与实现操作系统课程设计(含源文件)(3)

2018-12-29 22:08

((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->InsertString(i,buf); }

ReadyVec[0].status=0;

RunVec.push_back(ReadyVec[0]); tempRunPcb = ReadyVec[0];

((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->DeleteString(0); CString buf;

buf.Format(\ ((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->AddString(buf); }

else if(((((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->GetCount())!=0) && (ReadyVec.size()!=0)) {

RunVec[0].WorkTime-=100;

if ( RunVec[0].WorkTime <= 0) {

((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->ResetContent(); m_memSize+= ReadyVec[0].MemCount; runTime = 0;

RunVec.clear();

vector::iterator pos1 = ReadyVec.begin(); ReadyVec.erase(pos1); } }

else if (((((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->GetCount())!=0) && (ReadyVec.size()==0)) {

RunVec[0].WorkTime-=100;

if ( RunVec[0].WorkTime <= 0) {

((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->ResetContent(); m_memSize+= ReadyVec[0].MemCount; runTime = 0;

RunVec.clear();

vector::iterator pos1 = ReadyVec.begin(); ReadyVec.erase(pos1); } }

if ((((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->GetCount())!=0) {

if (WaitVec.size()!=0) {

sort(WaitVec.begin(),WaitVec.end(),Compare); for (int j = 0;j

[键入文字]

11

if (WaitVec[j].MemCount <=m_memSize) {

//删除掉可以进入就绪队列的优先权最高的进程 m_memSize-=WaitVec[j].MemCount; WaitVec[j].status=1;

ReadyVec.push_back(WaitVec[j]);

vector::iterator pos = &WaitVec[j]; WaitVec.erase(pos);

((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->DeleteString(j); CString buf;

buf.Format(\ ((CListBox

*)GetDlgItem(IDC_LIST_RUNPRO))->InsertString(ReadyVec.size(),buf);

} }

((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->ResetContent(); for (j = 0;j

CString buf ;

buf.Format(\

((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->InsertString(j,buf); }

} }

UpdateData(FALSE); }

else if (nIDEvent == 1)//最短作业优先算法 { if ((!ReadyVec.empty()) && ((((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->GetCount())==0)) {

std::stable_sort( ReadyVec.begin(),ReadyVec.end(),CompareByWkt); ((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->ResetContent(); for (int i = 0; i

CString buf ;

buf.Format(\

((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->InsertString(i,buf); }

ReadyVec[0].status=0;

RunVec.push_back(ReadyVec[0]); ReadyVec[0].WorkTime-=100;

tempRunPcb = ReadyVec[0]; CString buf;

[键入文字]

12

((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->GetText(0,buf); ((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->DeleteString(0); ((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->AddString(buf); UpdateData(false); }

else if (((((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->GetCount())!=0) && (ReadyVec.size()!=0)) {

ReadyVec[0].WorkTime-=100;

if ( ReadyVec[0].WorkTime <= 0) {

((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->ResetContent(); UpdateData(false);

m_memSize+= ReadyVec[0].MemCount; runTime = 0;

RunVec.clear();

vector::iterator pos1 = ReadyVec.begin(); ReadyVec.erase(pos1); }

//操作阻塞队列

stable_sort(WaitVec.begin(),WaitVec.end(),CompareByWkt); if (WaitVec.size()!=0) {

if (WaitVec[0].MemCount <= m_memSize) {

m_memSize-= WaitVec[0].MemCount; WaitVec[0].status=1;

ReadyVec.push_back(WaitVec[0]); vector::iterator pos = WaitVec.begin(); WaitVec.erase(pos); if (ReadyVec.size()!=0) {

((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->ResetContent(); for (int i = 0; i

CString buf ;

buf.Format(\ ((CListBox *)GetDlgItem(IDC_LIST_READYPRO))->InsertString(i,buf); }

UpdateData(false); }

((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->ResetContent(); for (int i = 0; i

13

[键入文字]

CString buf ;

buf.Format(\

((CListBox *)GetDlgItem(IDC_LIST_WAITPRO))->InsertString(i,buf); }

UpdateData(FALSE); } } }

else if (((((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->GetCount())!=0) && (ReadyVec.empty())) {

ReadyVec[0].WorkTime-=100;

if ( ReadyVec[0].WorkTime <= 0) {

((CListBox *)GetDlgItem(IDC_LIST_RUNPRO))->ResetContent(); UpdateData(FALSE); m_memSize+= ReadyVec[0].MemCount; runTime = 0;

RunVec.clear(); } } else {

UpdateData(FALSE); } }

8、测试数据及测试结果

8.1、运行时部分界面 刚启动时

[键入文字]

14

添加进程后:

先来先服务算法调度点击开始模拟后:

[键入文字]

15


模拟进程调度功能的设计与实现操作系统课程设计(含源文件)(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:福建省会计继续教育企业类初级会计人员培训班考题题库(0078)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: