www.pudn.com > OSDemo.rar > YemianDlg1.cpp
// YemianDlg1.cpp : implementation file // #include "stdafx.h" #include "OSDemo.h" #include "YemianDlg1.h" #include#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CYemianDlg dialog CYemianDlg::CYemianDlg(CWnd* pParent /*=NULL*/) : CDialog(CYemianDlg::IDD, pParent) { //{{AFX_DATA_INIT(CYemianDlg) m_memory = 0; m_total = 0; m_random = _T(""); m_change = 0; m_absent = 0; m_changef = 0.0; m_absentf = 0.0; //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CYemianDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CYemianDlg) DDX_Control(pDX, IDC_LIST1, m_list); DDX_Text(pDX, IDC_EDIT1, m_memory); DDX_Text(pDX, IDC_EDIT2, m_total); DDX_Text(pDX, IDC_EDIT3, m_random); DDX_Text(pDX, IDC_EDIT4, m_change); DDX_Text(pDX, IDC_EDIT6, m_absent); DDX_Text(pDX, IDC_EDIT5, m_changef); DDX_Text(pDX, IDC_EDIT7, m_absentf); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CYemianDlg, CDialog) //{{AFX_MSG_MAP(CYemianDlg) ON_BN_CLICKED(IDC_BUTTON1, OnFIFO) ON_BN_CLICKED(IDC_BUTTON2, OnLRU) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CYemianDlg message handlers BOOL CYemianDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. //先进先出页面置换算法 void CYemianDlg::OnFIFO() { UpdateData(1); CArray myt;//存放随机生成的所有页面号的数组 CArray mym;//存放物理块中现有的页面号 int m=0; int as=0;//置换页面计数 bool x; //页面是否需要置换 CString str1=""; CString str2=""; myt.SetSize(m_total,-1); mym.SetSize(m_memory,-1); if(m_memory myt; CArray mym; CArray myb; int m=0,a; int as=0; //置换页面计数 bool x; CString str1=""; CString str2=""; myt.SetSize(m_total,-1); mym.SetSize(m_memory,-1); myb.SetSize(m_memory,-1); if(m_memory