os实验指导书(新)1(2)

内容发布更新时间 : 2024/11/15 2:26:59星期一 下面是文章的全部内容请认真阅读。

__ ___

________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

步骤3:在“命令提示符”窗口加入参数重新运行生成的可执行文件。运行结果: 范例:E:\\课程\\os课\\os实验\\程序\\os11\\debug>os21 3 (假设编译生成的可执行文件是os21.exe) ____

11

____

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________

按下ctrl+alt+del,调用windows的任务管理器,记录进程相关的行为属性:

__ ____

12

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________

步骤4:修改清单2-1中的程序,将nClone的定义和初始化方法按程序注释中的修改方法进行修改,编译成可执行文件(执行前请先保存已经完成的工作)。再按步骤2中的方式运行,看看结果会有什么不一样。运行结果: 1.改为:int nClone; 将会无限循环,直至溢出内存。

_________________

______________________________________________________________________________________

13

_________________________________________________________________________________________________________________________________

从中你可以得出什么结论:

nClone的作用:_________________________________________________________________ _____________________________________________________________________ 变量的定义和初始化方法(位置)对程序的执行结果有影响吗?为什么?________________

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

(2). 父子进程的简单通信及终止进程

步骤1:创建一个“Win32 Consol Application”工程,然后拷贝清单2-2中的程序,编译成可执行文件。 步骤2:在VC的工具栏单击“Execute Program”(执行程序) 按钮,或者按Ctrl + F5键,或者在“命令提示符”窗口运行步骤1中生成的可执行文件。运行结果: 范例:E:\\课程\\os课\\os实验\\程序\\os11\\debug>os22 (假设编译生成的可执行文件是os22.exe)

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

步骤3:按源程序中注释中的提示,修改源程序2-2,编译执行(执行前请先保存已经完成的工作)。运行结果: _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

14

在程序中加入跟踪语句,或调试运行程序,同时参考MSDN中的帮助文件CreateProcess()的使用方法,理解父子进程如何传递参数。给出程序执行过程的大概描述:

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

步骤4:填空

CreateProcess() 函数有________个核心参数?本实验程序中设置的各个参数的值是: a. _________________________________________________; b. _________________________________________________; c. _________________________________________________; d. _________________________________________________; e. _________________________________________________; f. _________________________________________________; g. _________________________________________________; h. _________________________________________________。

步骤5:按源程序中注释中的提示,修改源程序2-2,编译执行。运行结果:

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

步骤6:参考MSDN中的帮助文件CreateMutex()、OpenMutex()、ReleaseMutex()和WaitForSingleObject()的使用方法,理解父子进程如何利用互斥体进行同步的。给出父子进程同步过程的一个大概描述:

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

3、 实验结论

_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

4、 程序清单

清单2-1 创建子进程 // proccreate项目

#include #include #include

15

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi