资源描述:
《计算机操作系统实验题目》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、题目1:Windows进程的创建与销毁内容及要求:①掌握Windows进程的创建和销毁API的调用方法;编程代码,在程序中创建和销毁一个Word进程;②能够挂起和激活被创建进程的主线程;③通过Windows进程管理器查看系统进程列表的变化。实验指导:①创建进程的APIBOOLCreateProcess(LPCTSTRlpApplicationName,LPTSTRlpCommandLine,LPSECURITY_ATTRIBUTESlpProcessAttributes,LPSECURITY_ATTRIBUTESlpThreadAttr
2、ibutes,BOOLbInheritHandles,DWORDdwCreationFlags,LPVOIDlpEnvironment,LPCTSTRlpCurrentDirectory,LPSTARTUPINFOlpStartupInfo,LPPROCESS_INFORMATIONlpProcessInformation);例程:voidmain(VOID){STARTUPINFOsi;PROCESS_INFORMATIONpi;ZeroMemory(&si,sizeof(si));si.cb=sizeof(si);ZeroMemor
3、y(&pi,sizeof(pi));//Startthechildprocess.if(!CreateProcess(NULL,//Nomodulename(usecommandline)."MyChildProcess",//Commandline.NULL,//Processhandlenotinheritable.NULL,//Threadhandlenotinheritable.FALSE,//SethandleinheritancetoFALSE.0,//Nocreationflags.NULL,//Useparent'sen
4、vironmentblock.NULL,//Useparent'sstartingdirectory.&si,//PointertoSTARTUPINFOstructure.&pi)//PointertoPROCESS_INFORMATIONstructure.){ErrorExit("CreateProcessfailed.");}//Waituntilchildprocessexits.WaitForSingleObject(pi.hProcess,INFINITE);//Closeprocessandthreadhandles.C
5、loseHandle(pi.hProcess);CloseHandle(pi.hThread);}②销毁进程APIBOOLTerminateProcess(HANDLEhProcess,UINTuExitCode);③挂起进程的主线程APIDWORDSuspendThread(HANDLEhThread);④激活进程的主线程APIDWORDResumeThread(HANDLEhThread);⑤进程查看器题目2:Windows进程间的通信内容及要求:①理解Windows进程间通信的原理,掌握Windows进程间通信的编程方法;②掌握W
6、indows管道的编程API调用方法;③编写两个不同的程序,使用管道方式实现这两个程序运行时进程间的通信。实验指导:创建管道的APIHANDLECreateNamedPipe(LPCTSTRlpName,DWORDdwOpenMode,DWORDdwPipeMode,DWORDnMaxInstances,DWORDnOutBufferSize,DWORDnInBufferSize,DWORDnDefaultTimeOut,LPSECURITY_ATTRIBUTESlpSecurityAttributes);连接管道的APIBOOLCon
7、nectNamedPipe(HANDLEhNamedPipe,LPOVERLAPPEDlpOverlapped);例程:handlesvrhandle;charpipenamestr[30];sprintf(pipenamestr,″\\.\pipe\pipename″)svrhandle=createnamedpipe(pipenamestr,pipe_access_duplex
8、file_flag_write_through,//阻塞模式,这种模式仅对″字节传输管道″操作有效。file_wait
9、pipe_type_byte
10、,//字节模式pipe_unlimited_instances,128,128,null,null);//security_attributes结构指针,描述一个新管道,确定子进程的继承权,如果为null则