((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
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
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 ((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 //操作阻塞队列 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 ((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