編程演示三種存儲管理方式的地址換算過程_第1頁
編程演示三種存儲管理方式的地址換算過程_第2頁
編程演示三種存儲管理方式的地址換算過程_第3頁
編程演示三種存儲管理方式的地址換算過程_第4頁
編程演示三種存儲管理方式的地址換算過程_第5頁
已閱讀5頁,還剩18頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、0內(nèi)蒙古師范大學(xué)計(jì)算機(jī)與信息工程學(xué)院操作系統(tǒng)課程設(shè)計(jì)報(bào)告設(shè)計(jì)題目編程演示三種存儲管理方式的地址換算過程指導(dǎo)教師翟煒職稱姓名聶斐斐學(xué)號20111501182日期2014.6.27計(jì)算機(jī)科學(xué)與技術(shù)專業(yè)課程設(shè)計(jì)任務(wù)書學(xué)生姓名聶斐斐專業(yè)班級13專升本學(xué)號20111501182題目編程演示三種存儲管理方式的地址換算過程課題性質(zhì)其它課題來源指導(dǎo)教師翟炸同組姓名無主要內(nèi)容1、分頁方式的地址換算2、分段方式的地址換算3、段頁式的地址換算任務(wù)要求要求演示正確、清晰,編程所用工具不限。奔f文獻(xiàn)張麗芬李侃劉利雄操作系統(tǒng)學(xué)習(xí)指導(dǎo)與習(xí)題解析電子工業(yè)出版社2006譚浩強(qiáng)C程序設(shè)計(jì)清華大學(xué)出版社 2008任滿杰等操作系統(tǒng)原

2、理實(shí)用教程電子工業(yè)出版社 2006湯亍瀛計(jì)算機(jī)操作系統(tǒng)(修訂版)西安電子科技大學(xué)出版社2001張堯?qū)W 史美林計(jì)算機(jī)操作系統(tǒng)教程實(shí)驗(yàn)指導(dǎo)清華大學(xué)出版社 2000羅宇等操作系統(tǒng)課程設(shè)計(jì)機(jī)械工業(yè)出版社2005審查意見指導(dǎo)教師簽字:教研室主任簽字:年月日說明:本表由指導(dǎo)教師填寫,由教研室主任審核后下達(dá)給選題學(xué)生,裝訂在設(shè)計(jì)(論文)首頁1 需求分析編程演示三種存儲管理方式的地址換算過程,分別為分頁方式的地址換算,分段方式的地址換算,段頁式的地址換算。分頁方式通過邏輯地址算出頁號與葉內(nèi)地址,然后通過頁表來實(shí)現(xiàn)向物理地址的轉(zhuǎn)換。分段方式通過段號和段內(nèi)地址得到物理地址。段葉式通過段號得到頁表首地址,通過頁號得

3、到塊號,進(jìn)而得到物理地址。2 概要設(shè)計(jì)程序主要有三個功能,分別是分頁方式的地址換算,分段方式的地址換算,段頁式的地址換算。利用可視化界面進(jìn)行選擇。3 運(yùn)行環(huán)境軟件環(huán)境:WindowXP, VisualC+6.04 開發(fā)工具和編程語言開發(fā)工具:VisualC+6.0編程語言:C+1言5 詳細(xì)設(shè)計(jì)5.1 流程圖1021開始段式地加札城5.2界面設(shè)計(jì)5.3代碼設(shè)計(jì)/ dizhizhuanhuanDlg.cpp : implementation file /#include "stdafx.h"#include "dizhizhuanhuan.h"#includ

4、e "dizhizhuanhuanDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE口 = _FILE_;#endif#include <stdlib.h>#include <stdio.h>int page(int A,int L );int Segment(int sn,int sl);int SegPagt(int sn,int pn,int pd);typedef struct segtable int segf256;int segl25

5、6;segtable;struct segtable st;typedef struct segpagt /int segf256;int segl4;int ptl;int pt3500;/int pf256;int pl;segpagt;struct segpagt sp;int i,j;int d,P;int A,L;int WD,wd;int PT4;int temp;int kd;int sn,sd;int pn,pd;/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutD

6、lg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CAboutDlg)DDX/DDVprotected:virtual void DoDataExchange(CDataExchange* pDX); / support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE

7、_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg) /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog) /AFX_MSG_MAP(CAboutDlg)/ No message handlers/AFX_MSG_M

8、APEND_MESSAGE_MAP()/ CDizhizhuanhuanDlg dialogCDizhizhuanhuanDlg:CDizhizhuanhuanDlg(CWnd* pParent /*=NULL*/) : CDialog(CDizhizhuanhuanDlg:IDD, pParent)/AFX_DATA_INIT(CDizhizhuanhuanDlg)m_A = _T("");m_L = _T("");m_s = _T("");m_sn = _T("");m_sd = _T(""

9、);m_sn1 = _T("");m_pn1 = _T("");m_pd1 = _T("");m_y1 = _T("");m_y2 = _T("");m_y3 = _T("");m_y4 = _T("");m_d0 = _T("");m_d1 = _T("");m_d2 = _T("");m_d3 = _T("");m_d00 = _T("");m_d11

10、= _T("");m_d22 = _T("");m_d33 = _T("");m_dy11 = _T("");m_dy12 = _T("");m_dy13 = _T("");m_dy14 = _T("");m_dy21 = _T("");m_dy22 = _T("");m_dy23 = _T("");m_dy24 = _T("");m_dy31 = _T(""

11、;);m_dy32 = _T("");m_dy33 = _T("");m_dy34 = _T("");/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);void CDizhizhuanhuanDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX

12、);/AFX_DATA_MAP(CDizhizhuanhuanDlg)DDX_Text(pDX, IDC_EDIT1, m_A);DDX_Text(pDX, IDC_EDIT2, m_L);DDX_Text(pDX, IDC_JEIGUO, m_s);DDX_Text(pDX, IDC_EDIT3, m_sn);DDX_Text(pDX, IDC_EDIT4, m_sd);DDX_Text(pDX, IDC_EDIT5, m_sn1);DDX_Text(pDX, IDC_EDIT6, m_pn1);/DDX_Text(pDX, IDC_EDIT7, m_pd1);DDX_Text(pDX, I

13、DC_Y1, m_y1);DDX_Text(pDX, IDC_Y2, m_y2);DDX_Text(pDX, IDC_Y3, m_y3);DDX_Text(pDX, IDC_Y4, m_y4);DDX_Text(pDX, IDC_D0, m_d0);DDX_Text(pDX, IDC_D1, m_d1);DDX_Text(pDX, IDC_D2, m_d2);DDX_Text(pDX, IDC_D3, m_d3);DDX_Text(pDX, IDC_D00, m_d00);DDX_Text(pDX, IDC_D11, m_d11);DDX_Text(pDX, IDC_D22, m_d22);D

14、DX_Text(pDX, IDC_D33, m_d33);DDX_Text(pDX, IDC_DY11, m_dy11);DDX_Text(pDX, IDC_DY12, m_dy12);DDX_Text(pDX, IDC_DY13, m_dy13);DDX_Text(pDX, IDC_DY14, m_dy14);DDX_Text(pDX, IDC_DY21, m_dy21);DDX_Text(pDX, IDC_DY22, m_dy22);DDX_Text(pDX, IDC_DY23, m_dy23);DDX_Text(pDX, IDC_DY24, m_dy24);DDX_Text(pDX, I

15、DC_DY31, m_dy31);DDX_Text(pDX, IDC_DY32, m_dy32);DDX_Text(pDX, IDC_DY33, m_dy33);DDX_Text(pDX, IDC_DY34, m_dy34);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CDizhizhuanhuanDlg, CDialog)/AFX_MSG_MAP(CDizhizhuanhuanDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_RADIO1, OnYeshi)ON_BN_CLIC

16、KED(IDC_RADIO2, OnDuanshi)ON_BN_CLICKED(IDC_RADIO3, OnDuanyeshi)ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)ON_BN_CLICKED(IDC_BUTTON1, OnButton1)/ ON_BN_CLICKED(IDC_BUTTON2, OnButton2)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CDizhizhuanhuanDlg message handlersBOOL CDizhizhuanhuanDlg:OnInitDialog()CDialog:OnInitDial

17、og();/ Add "About." menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL)CString strAboutMenu;strAboutMenu.LoadString(IDS_AB

18、OUTBOX);if (!strAboutMenu.IsEmpty()pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRINGID,M_ABOUTBOXst,rAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);/ Set big iconSet

19、Icon(m_hIcon, FALSE); / Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a control void CDizhizhuanhuanDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal(); else CDialog:OnSysComma

20、nd(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFCapplications using the document/view model, / this is automatically done for you by the framework.void CDizhizhuanhuanDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context

21、for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint 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)

22、/ 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CDizhizhuanhuanDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CDizhizhuanhuanDlg:OnYeshi()/ TODO: Add your control notifi

23、cation handler code hereUpdateData(true);YS();UpdateData(false);xz=1;void CDizhizhuanhuanDlg:OnDuanshi()/ TODO: Add your control notification handler code hereUpdateData(true);DS();UpdateData(false);xz=2;void CDizhizhuanhuanDlg:OnDuanyeshi()/ TODO: Add your control notification handler code here Upd

24、ateData(true);DYS();UpdateData(false);xz=3;void CDizhizhuanhuanDlg:OnChangeEdit1()the/ TODO: If this is a RICHEDIT control, the control will not/ send this notification unless you override CDialog:OnInitDialog()/ function and call CRichEditCtrl().SetEventMask()/ with the ENM_CHANGE flag ORed into th

25、e mask./ TODO: Add your control notification handler code herevoid CDizhizhuanhuanDlg:OnButton1()/ TODO: Add your control notification handler code hereUpdateData(true);if(xz=1)A=(int)atof(m_A);L=(int)atof(m_L);P=A/L;d=A%L;if(P>=4) m_s=(CString)" 頁號大于頁表長度, 越界中斷n"elsekd=PTP;/ 根據(jù)頁號隨機(jī)產(chǎn)生快號W

26、D=kd*L+d;/ 計(jì)算物理地址的公式temp=WD;m_s.Format("%d",temp);/ return (0);if(xz=2)sn=(int)atof(m_sn);sd=(int)atof(m_sd);if(sn>4)m_s=(CString)" 段號大于段表長度4, 越界中斷"else if(sd>st.seglsn)m_s=(CString)" 段內(nèi)地址大于段長度, 越界中斷"elsewd=st.segfsn+sd;/ 計(jì)算物理地址的算法temp=wd;m_s.Format("%d"

27、,temp);if(xz=3)sn=(int)atof(m_sn1);/段號A=(int)atof(m_pn1);/邏輯地址/pd=(int)atof(m_pd1);pn=A/1024;pd=A%1024;if(sn>3)m_s=(CString)"段號大于段表長度3, 越界中斷"else if(pn>=4)m_s=(CString)"頁號大于頁表長度4, 越界中斷"elsekd=sp.ptsn-1pn-1;wd=kd*1024+pd;/ 計(jì)算物理地址的公式temp=wd;m_s.Format("%d",temp);Upd

28、ateData(false); int CDizhizhuanhuanDlg:YS()/int d,P,kd,i;/int A,L;/int WD;/int PT4;for(i=1;i<=4;i+)PTi=rand() %500;/m_y1.Format("%d",PT1);m_y2.Format("%d",PT2);m_y3.Format("%d",PT3);m_y4.Format("%d",PT4);return (0); int CDizhizhuanhuanDlg:DS()/int i,wd;/int

29、 sn,sd;for(i=0;i<4;i+)st.segfi=rand()%200;/st.segli=rand()%2000;/1 到 500之間定義隨機(jī)產(chǎn)生段首地址定義隨機(jī)產(chǎn)生段長度m_d0.Format("%d",st.segf0);m_d1.Format("%d",st.segf1);m_d2.Format("%d",st.segf2);m_d3.Format("%d",st.segf3);m_d00.Format("%d",st.segl0);m_d11.Format("

30、;%d",st.segl1);m_d22.Format("%d",st.segl2);m_d33.Format("%d",st.segl3);return (0); int CDizhizhuanhuanDlg:DYS()/int i,j,wd,kd;/int sn,pn,pd,A;sp.ptl =1024;sp.pl=4;for(i=0;i<3;i+)for(j=0;j<4;j+)定義隨機(jī)產(chǎn)生的數(shù)在1 到 256 之間sp.ptij=rand()%500;/m_dy11.Format("%d",sp.pt00)

31、;m_dy12.Format("%d",sp.pt01);m_dy13.Format("%d",sp.pt02);m_dy14.Format("%d",sp.pt03);m_dy21.Format("%d",sp.pt10);m_dy22.Format("%d",sp.pt11);m_dy23.Format("%d",sp.pt12);m_dy24.Format("%d",sp.pt13);m_dy31.Format("%d",sp.pt20);m_dy32.Format("%d",sp.pt21);m_dy33.Format

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論