文件名称:JobObject
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:1.1kb
-
已下载:1次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
通过windows的内核对象JobObject实现对程序的运行时间和内存使用的控制,开发初衷是作为一个简陋的acm判题沙箱.
大致步骤:
1.通过CreateJobObject创建一个工作对象
2.通过SetInformationJobObject设置工作对象的参数,详见MSDN(http://msdn.microsoft.com/zh-cn/library/ms686216)
3.以CREATE_SUSPENDED方式启动进程,通过CreateProcessAsUser或者CreateProcess函数,可能还有其他函数,未做研究.
4.通过AssignProcessToJobObject将工作对象应用到指定进程中.
5.通过ResumeThread恢复已暂停的进程.
6.通过WaitForSingleObject等待正在运行的工作对象,设置好允许使用时间.
7.通过QueryInformationJobObject获取工作对象的最终状态.运行程序的退出状态可以通过GetExitCodeProcess获取.
8.扫尾工作(必须使用TerminateJobObject结束当前的工作对象,因为工作对象即便设置了PerProcessUserTimeLimit也无法使程序在超时后退出,没有研究原因).
编译时请包含Kernel32.lib.-By the windows kernel objects JobObject control program run time and memory usage, originally developed as a rudimentary the acm sentenced Title sandbox. Roughly steps: 1. Through CreateJobObject create a work object 2. Through SetInformationJobObject set object parameters, see the MSDN (http://msdn.microsoft.com/zh-cn/library/ms686216) start the process to CREATE_SUSPENDED way through CreateProcessAsUser or CreateProcess function, may have other functions, without making research. by AssignProcessToJobObject work object applied to the specified process. 5. through ResumeThread recovery process has been suspended. 6. WaitForSingleObject to wait for running work object, set up to allow the use of time. through QueryInformationJobObject get the final state of the work objects run the program exit the state by GetExitCodeProcess get off the work (must use TerminateJobObject the end of the current work object, because the work object even set PerProcessUserTimeLimit can not make the prog
大致步骤:
1.通过CreateJobObject创建一个工作对象
2.通过SetInformationJobObject设置工作对象的参数,详见MSDN(http://msdn.microsoft.com/zh-cn/library/ms686216)
3.以CREATE_SUSPENDED方式启动进程,通过CreateProcessAsUser或者CreateProcess函数,可能还有其他函数,未做研究.
4.通过AssignProcessToJobObject将工作对象应用到指定进程中.
5.通过ResumeThread恢复已暂停的进程.
6.通过WaitForSingleObject等待正在运行的工作对象,设置好允许使用时间.
7.通过QueryInformationJobObject获取工作对象的最终状态.运行程序的退出状态可以通过GetExitCodeProcess获取.
8.扫尾工作(必须使用TerminateJobObject结束当前的工作对象,因为工作对象即便设置了PerProcessUserTimeLimit也无法使程序在超时后退出,没有研究原因).
编译时请包含Kernel32.lib.-By the windows kernel objects JobObject control program run time and memory usage, originally developed as a rudimentary the acm sentenced Title sandbox. Roughly steps: 1. Through CreateJobObject create a work object 2. Through SetInformationJobObject set object parameters, see the MSDN (http://msdn.microsoft.com/zh-cn/library/ms686216) start the process to CREATE_SUSPENDED way through CreateProcessAsUser or CreateProcess function, may have other functions, without making research. by AssignProcessToJobObject work object applied to the specified process. 5. through ResumeThread recovery process has been suspended. 6. WaitForSingleObject to wait for running work object, set up to allow the use of time. through QueryInformationJobObject get the final state of the work objects run the program exit the state by GetExitCodeProcess get off the work (must use TerminateJobObject the end of the current work object, because the work object even set PerProcessUserTimeLimit can not make the prog
(系统自动生成,下载前可以参看下载内容)
下载文件列表
main.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.