📄 win页面置换view.cpp
字号:
// WIN页面置换View.cpp : implementation of the CWINView class
//
#include "stdafx.h"
#include "WIN页面置换.h"
#include "WIN页面置换Doc.h"
#include "WIN页面置换View.h"
//初始化对话框
#include "InitDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWINView
IMPLEMENT_DYNCREATE(CWINView, CView)
BEGIN_MESSAGE_MAP(CWINView, CView)
//{{AFX_MSG_MAP(CWINView)
ON_COMMAND(ID_MENU_ONINITDATA, OnMenuOninitdata)
ON_COMMAND(ID_MENU_START, OnMenuStart)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWINView construction/destruction
CWINView::CWINView()
{
// TODO: add construction code here
m_dispay=0;
}
CWINView::~CWINView()
{
}
BOOL CWINView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CWINView drawing
void CWINView::OnDraw(CDC* pDC)
{
CWINDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
extern int m_text;
if((m_dispay<=m_text)&&(m_dispay!=0))
{ //CDC *pDC=GetDC();
CString n;
n.Format("现在执行第%d条指令",m_dispay);
pDC->TextOut(100,45,n);
n="";
switch(main.m_scout[m_dispay].m_state)//指令状态输出
{
case(1):
{
n.Format("指令由%d顺序执行到---->%d",main.m_scout[m_dispay].m_CurrptrDictateProgram,main.m_scout[m_dispay].m_NextDictateProgram);
pDC->TextOut(110,75,n);
n="";
n.Format("指令所在的内存块号%d,偏移地址%d,对应的页号%d",main.m_scout[m_dispay].m_dictate.m_memoryblock,main.m_scout[m_dispay].m_dictate.m_logicAdress,main.m_scout[m_dispay].m_dictate.m_page);
pDC->TextOut(110,105,n);
break;
}
case(2):
{
n.Format("指令由%d往后跳执行到---->%d",main.m_scout[m_dispay].m_CurrptrDictateProgram,main.m_scout[m_dispay].m_NextDictateProgram);
pDC->TextOut(110,75,n);
n="";
n.Format("指令所在的内存块号%d,偏移地址%d,对应的页号%d",main.m_scout[m_dispay].m_dictate.m_memoryblock,main.m_scout[m_dispay].m_dictate.m_logicAdress,main.m_scout[m_dispay].m_dictate.m_page);
pDC->TextOut(110,105,n);
break;
}
case(3):
{
n.Format("指令由%d往前跳执行到--->%d",main.m_scout[m_dispay].m_CurrptrDictateProgram,main.m_scout[m_dispay].m_NextDictateProgram);
pDC->TextOut(110,75,n);
n="";
n.Format("指令所在的内存块号%d,偏移地址%d,对应的页号%d",main.m_scout[m_dispay].m_dictate.m_memoryblock,main.m_scout[m_dispay].m_dictate.m_logicAdress,main.m_scout[m_dispay].m_dictate.m_page);
pDC->TextOut(110,105,n);
break;
}//end case
}//end switch
switch(main.m_scout[m_dispay].m_missState)
{
case(1):
{
n="命中--->下一条指令在内存中";
pDC->TextOut(110,135,n);
break;
}
case(2):
{
n="没有命中--->下一条指令在不在内存中,但是内存有空闲";
pDC->TextOut(110,135,n);
break;
}
case(3):
{
n="没有命中--->内存不空闲,需要进行页面置换";
pDC->TextOut(110,135,n);
break;
}
}
}
else
;
}
/////////////////////////////////////////////////////////////////////////////
// CWINView diagnostics
#ifdef _DEBUG
void CWINView::AssertValid() const
{
CView::AssertValid();
}
void CWINView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CWINDoc* CWINView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWINDoc)));
return (CWINDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWINView message handlers
void CWINView::OnMenuOninitdata()
{
// TODO: Add your command handler code here
CInitDlg Dlg;
if(Dlg.DoModal()==IDOK)
{
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;// 得到主框架指针
pFrame->SendMessage(WM_MYMESSAGE,0,0);
}
}
void CWINView::OnMenuStart()
{
// TODO: Add your command handler code here
main.Oninit();
main.MainFuntion();
CString dd;
float f;
extern int m_text;
f=(main.failnuber*100)/(float)m_text;
dd.Format("没有命中的指令数目为%d\n缺页率为%f%%",main.failnuber,f);
MessageBox(dd);
SetTimer(0,790,NULL);
}
void CWINView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
m_dispay++;
CView::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -