资源描述:
《操作系统进程调度算法模拟__mfc实现》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、技术资料#include"windows.h"#include"windowsx.h"#include"tchar.h"#include"strsafe.h"#include"resource.h"#pragmawarning(disable:4312)#pragmawarning(disable:4244)#defineEDITLEN20#defineRR2//时间片#definechHANDLE_DLGMSG(hWnd,message,fn)case(message):return(SetDlg
2、MsgResult(hWnd,uMsg,HANDLE_##message((hWnd),(wParam),(lParam),(fn))))structProcInfo{intprocID;//进程IDfloatarriveT;//达到时间floatserverT;//服务时间floatremainT;//剩余运行时间floatlastrunT;//上次运行时间floatrunT;//运行时间总和floatpriority;//优先级,高响应比优先调度算法时初始为1,其他算法未用到,初始为0struc
3、tProcInfo*next;//下一结点}*startProc,*endProc;HWNDhWnd;/*检查6个进程的到达时间和服务时间是否已经全部输入已经全部输入返回TRUE,否则返回FALSE*/boolCheckEdits(){wchar_tstr[EDITLEN];for(inti=IDC_A1;i<=IDC_F1;i+=5){GetDlgItemText(hWnd,i,str,EDITLEN);if(lstrcmp(str,_T(" "))==0)returnfalse;GetDlgIt
4、emText(hWnd,i+1,str,EDITLEN);共享知识技术资料if(lstrcmp(str,_T(" "))==0)returnfalse;}returntrue;}/*计算平均周转时间和平均带权周转时间,并显示*/voidShowEdits(){floatzzsj=0,pjzz=0;wchar_tstr[10];for(inti=IDC_A4;i<=IDC_F4;i+=5){GetDlgItemText(hWnd,i,str,10);zzsj+=_wtof(str);GetDlgIte
5、mText(hWnd,i+1,str,10);pjzz+=_wtof(str);}StringCchPrintf(str,10,_T("%f"),zzsj/6);SetDlgItemText(hWnd,IDC_TIME1,str);StringCchPrintf(str,10,_T("%f"),pjzz/6);SetDlgItemText(hWnd,IDC_TIME2,str);}/*清除所有编辑框的内容*/voidClearEdits(){for(inti=IDC_A1;i6、i++){SetWindowText(GetDlgItem(hWnd,i),_T(""));}}/*在链表尾部插入node结点*/voidInsertNode(ProcInfo*node){共享知识技术资料if(startProc==NULL){startProc=endProc=node;}else{endProc->next=node;endProc=node;if(startProc->next==NULL){startProc->next=endProc;}}}/*移除链表头结点*/voidR
7、emoveNode(){if(startProc!=NULL){floatfinishT;wchar_tstr[10];ProcInfo*tmp=startProc;if(startProc->next!=NULL){startProc=startProc->next;startProc->lastrunT=tmp->lastrunT+tmp->remainT;}else{startProc=endProc=NULL;}finishT=tmp->lastrunT+tmp->remainT;String
8、CchPrintf(str,10,_T("%f"),finishT);SetDlgItemText(hWnd,IDC_A3+5*tmp->procID,str);StringCchPrintf(str,10,_T("%f"),finishT-tmp->arriveT);SetDlgItemText(hWnd,IDC_A4+5*tmp->procID,str);StringCchPrintf(str,10,_T("%f"),(finishT-tmp->ar