进程通信实验报告.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《进程通信实验报告.docx》由会员分享,可在线阅读,更多相关《进程通信实验报告.docx(46页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、西安电子科技大学操作系统原理试验报告题目:进程通信试验报告班级:030912 姓名:王增祥学号:03091168试验内容补充说明: 一、分析和设计1. 理论分析每个Windows进程都是由一个执行体进程块EPROCESS表示。API函数CreatProcess 可以创立进程,承受管道技术可以实现进程间的相互通信。建立pipe,进程以及其子进程就 可以对该管道进程读写共享,管道读写操作利用,write、read、close进展。父进程利用pipe 发送消息,子进程利用该pipe接收父进程发来的消息;子进程利用管道向父进程发送应答, 父进程利用该pipe承受应答。2. 总体设计1、利用CreatP
2、rocess函数创立进程。2、创立管道,实现进程间的通信二、具体实现1、创立界面,承受Botton、列表框等控件创立父子界面如以下图: 父进程界面:子进程界面:其中父进程各个空间创立类向导如图:子进程创立类向导如图:2. 父进程编写(1) 创立管道:(2) 创立子进程:(3) 消息发送(4) 消息承受3. 子进程编写(1) 发送消息(2) 读消息三、试验结果点击创立子进程按钮:在创立子进程之后进展进程间的通信如以下图四、心得体会1、从试验的角度了解了进程间是怎样利用管道进展通信的,了解了进程间通信的实际过程2、进一步把握了MFC的初步编程技巧,知道了怎样调试程序。3进一步了解了,API函数的应
3、用,明白了怎样进展界面编程。4、进一步生疏了在进展进程通信的编写过程中的各个细节。六、附录Process_Father.cpp#include “stdafx.h“#include “Process_Father.h“ /包含已编写的Process_Father.h头文件#include “Process_FatherDlg.h“ /包含已编写的Process_FatherDlg.h头文件/进展宏定义#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE =FILE; #endif/创立父进程BEGIN_M
4、ESSAGE_MAP(CProcess_FatherApp, CWinApp)/AFX_MSG_MAP(CProcess_FatherApp)/ NOTE - the ClassWizard will add and remove mapping macros here./DO NOT EDIT what you see in these blocks of generated code!/AFX_MSGON_COMMAND(ID_HELP, CWinApp:OnHelp) END_MESSAGE_MAP/ CProcess_FatherApp constructionCProcess_Fat
5、herApp:CProcess_FatherApp/ TODO: add construction code here,/ Place all significant initialization in InitInstance/ The one and only CProcess_FatherApp object CProcess_FatherApp theApp;/ CProcess_FatherApp initializationBOOL CProcess_FatherApp:InitInstanceAfxEnableControlContainer; #ifdef _AFXDLLEna
6、ble3dControls;/ Call this when using MFC in a shared DLL #elseEnable3dControlsStatic;/ Call this when linking to MFC statically #endifCProcess_FatherDlg dlg; m_pMainWnd = &dlg;int nResponse = dlg.DoModal; if (nResponse = IDOK)/ TODO: Place code here to handle when the dialog is/ dismissed with OKels
7、e if (nResponse = IDCANCEL)/ TODO: Place code here to handle when the dialog is/ dismissed with Cancel/ Since the dialog has been closed, return FALSE so that we exit the/ application, rather than start the application”s message pump. return FALSE;Process_FatherDlg.cpp/ Process_FatherDlg.cpp : imple
8、mentation file/#include “stdafx.h“ #include “Process_Father.h“#include “Process_FatherDlg.h“#ifdef _DEBUG#define new DEBUG_NEW #undef THIS_FILEstatic char THIS_FILE =FILE; #endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg;/ Dialog Data/AFX_DATA(CAboutDlg)enu
9、m 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:CAboutDlg : CDialog(CAb
10、outDlg: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_MAP END_MESSAGE_MAP/ CProcess_FatherDlg dialog
11、CProcess_FatherDlg:CProcess_FatherDlg(CWnd* pParent /*=NULL*/): CDialog(CProcess_FatherDlg:IDD, pParent)/AFX_DATA_INIT(CProcess_FatherDlg)/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp-LoadIcon(IDR_MAINFRAME);void CProcess_FatherDlg:DoDataEx
12、change(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CProcess_FatherDlg)DDX_Control(pDX, IDC_BT_CreateChildProcess, m_BT_CreateChildProcess);DDX_Control(pDX, IDC_Send, m_Send);DDX_Control(pDX, IDC_LISTBOX_Record, m_LISTBOX_Record); DDX_Control(pDX, IDC_EDIT_Message, m_EDIT_Message);/A
13、FX_DATA_MAPBEGIN_MESSAGE_MAP(CProcess_FatherDlg, CDialog)/AFX_MSG_MAP(CProcess_FatherDlg) ON_WM_SYSCOMMANDON_WM_PAINT ON_WM_QUERYDRAGICONON_BN_CLICKED(IDC_BT_CreateChildProcess, OnBTCreateChildProcess) ON_BN_CLICKED(IDC_Send, OnSend)/AFX_MSG_MAPON_MESSAGE(WM_CHILD_SEND,OnReceiveMsg)END_MESSAGE_MAP/
14、CProcess_FatherDlg message handlersBOOL CProcess_FatherDlg:OnInitDialogCDialog:OnInitDialog;/ 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 AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_ST
15、RING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the application”s main window is not a dialogSetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE);/ Set big icon/ Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unl
16、ess you set the focus to a controlvoid CProcess_FatherDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout; dlgAbout.DoModal;elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. Fo
17、r MFC applications using the document/view model,/ this is automatically done for you by the framework.void CProcess_FatherDlg:OnPaintif (IsIconic)CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc, 0);/ Center icon in client rectangleint cxIcon = G
18、etSystemMetrics(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);elseCDialog:OnPaint;/ The system calls this to obtain the cursor to display w
19、hile the user drags/ the minimized window.HCURSOR CProcess_FatherDlg:OnQueryDragIconreturn (HCURSOR) m_hIcon;void CProcess_FatherDlg:OnBTCreateChildProcess/创立管道SECURITY_ATTRIBUTES sa;sa.nLength=sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor=NULL; sa.bInheritHandle=TRUE;:CreatePipe(&hPipeRead,&
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 进程 通信 实验 报告
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内