2022年FIFO页面置换算法 .pdf

上传人:Che****ry 文档编号:27254798 上传时间:2022-07-23 格式:PDF 页数:11 大小:69.86KB
返回 下载 相关 举报
2022年FIFO页面置换算法 .pdf_第1页
第1页 / 共11页
2022年FIFO页面置换算法 .pdf_第2页
第2页 / 共11页
点击查看更多>>
资源描述

《2022年FIFO页面置换算法 .pdf》由会员分享,可在线阅读,更多相关《2022年FIFO页面置换算法 .pdf(11页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、#include stdafx.h #include test.h #include testDlg.h#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE = _FILE_; #endifstruct SeqQueue *tier=NULL; BOOL flag; / / CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog public: CAboutDlg();/ Dialog Data /AFX_DATA(CA

2、boutDlg) enum IDD = IDD_ABOUTBOX ; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL/ Implementation protected: /AFX_MSG(CAboutDlg) /AFX_MSG DECLARE_MESSAGE_MAP() ;CAboutDlg:

3、CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAboutDlg) /AFX_DATA_INIT 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 11 页 - - - - - - - - - void CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CAboutDlg) /AFX_DATA

4、_MAP BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) /AFX_MSG_MAP(CAboutDlg) / No message handlers /AFX_MSG_MAP END_MESSAGE_MAP()/ / CTestDlg dialogCTestDlg:CTestDlg(CWnd* pParent /*=NULL*/) : CDialog(CTestDlg:IDD, pParent) /AFX_DATA_INIT(CTestDlg) / NOTE: the ClassWizard will add member initialization here /

5、AFX_DATA_INIT / Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME); void CTestDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CTestDlg) DDX_Control(pDX, IDC_BACK, m_back); /AFX_DATA_MAP BEGIN_MESSAGE_M

6、AP(CTestDlg, CDialog) /AFX_MSG_MAP(CTestDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_COMMAND(ID_EXIT, OnExit) ON_COMMAND(ID_ABOUT, OnAbout) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_COMMAND(ID_RESTART, OnRestart) ON_BN_CLICKED(IDC_BUTTON3, OnBut

7、ton3) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 11 页 - - - - - - - - - ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnButton6) ON_BN_CLICKED(IDC_BUTTON7, OnButton7) ON_BN_CLICKED(IDC_BUTTON8, OnButt

8、on8) ON_WM_SHOWWINDOW() ON_WM_TIMER() /AFX_MSG_MAP END_MESSAGE_MAP()/ / CTestDlg message handlersvoid Permute(short int x) flag=true; for(int i=0;irear;i+) if(x=tier-pagei) flag=false; return; tier-ptr=(tier-ptr+1)%MAXNUM; tier-pagetier-front=x; tier-front=(tier-front+1)%MAXNUM; tier-rear=tier-rearM

9、AXNUM?MAXNUM:tier-rear+1; void CTestDlg:InitDemo() for (int i=0;iSetBitmap(HBITMAP(hBlt); tier-front=0; tier-rear=0; tier-ptr=-1; flag=true; BOOL CTestDlg:OnInitDialog() CDialog:OnInitDialog(); / Add About. menu item to system menu.名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - -

10、- - - - - 第 3 页,共 11 页 - - - - - - - - - / IDM_ABOUTBOX must be in the system command range. ASSERT(IDM_ABOUTBOX & 0 xFFF0) = IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR); pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); / Set the icon for this dialog. The framework does th

11、is automatically / when the applications main window is not a dialog SetIcon(m_hIcon, TRUE); / Set big icon SetIcon(m_hIcon, FALSE); / Set small icon / TODO: Add extra initialization here MoveWindow(0,0,WIDTH+6,HEIGHT+44); CenterWindow(); bitmap.LoadBitmap(IDB_BACK); GetDlgItem(IDC_BACK)-MoveWindow(

12、0,0,640,480,TRUE); GetDlgItem(IDC_STATIC1)-MoveWindow(73,189,75,97,TRUE); m_Button0=(CButton*)GetDlgItem(IDC_BUTTON1); m_Button1=(CButton*)GetDlgItem(IDC_BUTTON2); m_Button2=(CButton*)GetDlgItem(IDC_BUTTON3); m_Button3=(CButton*)GetDlgItem(IDC_BUTTON4); m_Button4=(CButton*)GetDlgItem(IDC_BUTTON5); m

13、_Button5=(CButton*)GetDlgItem(IDC_BUTTON6); m_Button6=(CButton*)GetDlgItem(IDC_BUTTON7); m_Button7=(CButton*)GetDlgItem(IDC_BUTTON8); m_Static0=(CStatic*)GetDlgItem(IDC_STATIC1); m_Static1=(CStatic*)GetDlgItem(IDC_STATIC2); m_Static2=(CStatic*)GetDlgItem(IDC_STATIC3); m_Static3=(CStatic*)GetDlgItem(

14、IDC_STATIC4); m_Static4=(CStatic*)GetDlgItem(IDC_STATIC5); m_Static5=(CStatic*)GetDlgItem(IDC_STATIC6); m_Blt0.LoadBitmap(IDB_BITMAP1); m_Blt1.LoadBitmap(IDB_BITMAP2); m_Blt2.LoadBitmap(IDB_BITMAP3); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 11 页 - - - - -

15、 - - - - m_Blt3.LoadBitmap(IDB_BITMAP4); m_Blt4.LoadBitmap(IDB_BITMAP5); m_Blt5.LoadBitmap(IDB_BITMAP6); m_Blt6.LoadBitmap(IDB_BITMAP7); m_Blt7.LoadBitmap(IDB_BITMAP8); hBlt = :LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP0); int i; for (i=0;iMoveWindow(9+78*i,HEIGHT-120,75,97,TRUE);

16、m_Buttoni-SetBitmap(HBITMAP(m_Blti); for (i=0;iMoveWindow(76+102*i,(HEIGHT-120)/2,75,97,TRUE); m_Statici-MoveWindow(WIDTH-100,20,75,97,TRUE); GetDlgItem(IDC_STATIC)-MoveWindow(WIDTH-113,120,100,20,TRUE); tier=(SeqQueue*)malloc(sizeof(struct SeqQueue); InitDemo(); return TRUE; / return TRUE unless yo

17、u set the focus to a control void CTestDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID & 0 xFFF0) = IDM_ABOUTBOX) CAboutDlg dlgAbout; dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC a

18、pplications using the document/view model, / this is automatically done for you by the framework.void CTestDlg:DrawBackdrop() BITMAP bm; CDC *pDC=new CDC; CClientDC dc(&m_back); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 11 页 - - - - - - - - - pDC-CreateCom

19、patibleDC(&dc); pDC-SelectObject(bitmap); bitmap.GetObject(sizeof(BITMAP),&bm); dc.StretchBlt(0,0,640,480,pDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY); delete pDC; void CTestDlg:OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc

20、(), 0); / Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; / Draw the icon dc.DrawIcon(x, y, m_hIcon); else CDialog:

21、OnPaint(); DrawBackdrop(); / The system calls this to obtain the cursor to display while the user drags / the minimized window. HCURSOR CTestDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon; void CTestDlg:OnExit() / TODO: Add your command handler code here OnCancel(); 名师资料总结 - - -精品资料欢迎下载 - - - - - -

22、- - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 11 页 - - - - - - - - - void CTestDlg:OnCancel() / TODO: Add your message handler code here if( :MessageBox(GetSafeHwnd(), 退出程序吗 ?, 系统提示 , MB_YESNO|MB_ICONQUESTION|M B_DEFBUTTON2 ) = IDYES ) DeleteObject(hBlt); CDialog:OnCancel(); void CTestDlg:OnA

23、bout() / TODO: Add your command handler code here CAboutDlg dlg; dlg.DoModal(); void CTestDlg:OnRestart() / TODO: Add your command handler code here InitDemo(); void CTestDlg:SetImage(int n) Permute(n); if(flag) m_Statictier-ptr-SetBitmap(HBITMAP(m_Bltn); m_StaticSTNUM -1-SetBitmap(HBITMAP(m_Bltn);

24、else m_StaticSTNUM -1-SetBitmap(HBITMAP(hBlt); void CTestDlg:OnButton1() / TODO: Add your control notification handler code here SetImage(0); void CTestDlg:OnButton2() / TODO: Add your control notification handler code here 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - -

25、- 第 7 页,共 11 页 - - - - - - - - - SetImage(1); void CTestDlg:OnButton3() / TODO: Add your control notification handler code here SetImage(2); void CTestDlg:OnButton4() / TODO: Add your control notification handler code here SetImage(3); void CTestDlg:OnButton5() / TODO: Add your control notification

26、handler code here SetImage(4); void CTestDlg:OnButton6() / TODO: Add your control notification handler code here SetImage(5); void CTestDlg:OnButton7() / TODO: Add your control notification handler code here SetImage(6); void CTestDlg:OnButton8() / TODO: Add your control notification handler code he

27、re SetImage(7); void CTestDlg:OnShowWindow(BOOL bShow, UINT nStatus) CDialog:OnShowWindow(bShow, nStatus); / TODO: Add your message handler code here 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 11 页 - - - - - - - - - BOOL CTestDlg:Create(LPCTSTR lpszClassNam

28、e, LPCTSTR lpszWindowName, DWORD dwStyle, constRECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) / TODO: Add your specialized code here and/or call the base class return CDialog:Create(IDD, pParentWnd); void CTestDlg:OnTimer(UINT nIDEvent) / TODO: Add your message handler code here a

29、nd/or call default CDialog:OnTimer(nIDEvent); / testDlg.h : header file /#if !defined(AFX_TESTDLG_H_BC831C21_F558_4681_8EA8_512BDD43AAA8_INCLUDED_) #define AFX_TESTDLG_H_BC831C21_F558_4681_8EA8_512BDD43AAA8_INCLUDED_#if _MSC_VER 1000 #pragma once #endif / _MSC_VER 1000#define WIDTH 640 #define HEIGH

30、T 480 #define BTNUM 8 #define STNUM 6 #define MAXNUM 5struct SeqQueue short int pageMAXNUM; int ptr; int front,rear; ;/ / CTestDlg dialogclass CTestDlg : public CDialog / Construction public: CTestDlg(CWnd* pParent = NULL); / standard constructor名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - -

31、 - 名师精心整理 - - - - - - - 第 9 页,共 11 页 - - - - - - - - - CBitmap bitmap; CStatic* m_StaticSTNUM; CButton* m_ButtonBTNUM; HBITMAP hBlt; CBitmap m_BltBTNUM; / Dialog Data /AFX_DATA(CTestDlg) enum IDD = IDD_TEST_DIALOG ; CStatic m_back; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VI

32、RTUAL(CTestDlg) public: virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL/ Implementation protect

33、ed: void DrawBackdrop(); void InitDemo(); void SetImage(int n); HICON m_hIcon; / Generated message map functions /AFX_MSG(CTestDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnExit(); virtu

34、al void OnCancel(); afx_msg void OnAbout(); afx_msg void OnButton1(); afx_msg void OnButton2(); afx_msg void OnRestart(); afx_msg void OnButton3(); afx_msg void OnButton4(); afx_msg void OnButton5(); afx_msg void OnButton6(); afx_msg void OnButton7(); afx_msg void OnButton8(); 名师资料总结 - - -精品资料欢迎下载 -

35、 - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 11 页 - - - - - - - - - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); afx_msg void OnTimer(UINT nIDEvent); /AFX_MSG DECLARE_MESSAGE_MAP() ;/AFX_INSERT_LOCATION / Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_TESTDLG_H_BC831C21_F558_4681_8EA8_512BDD43AAA8_INCLUDED_)Trackback: http:/ - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 11 页 - - - - - - - - -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁