Description:
box uses user time
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r130:db5312fad511 - - 1 file changed: 26 inserted, 4 deleted

@@ -343,10 +343,32
343 ifsuccess = EXE_RESULT_MEMORY;
343 ifsuccess = EXE_RESULT_MEMORY;
344 }
344 }
345
345
346 - if((ifsuccess == EXE_RESULT_MEMORY) ||
346 + //printf("PID: %d\n", pi.dwProcessId);
347 - (WaitForSingleObject(pi.hProcess,
347 +
348 - (int)(t*1000) + 1
348 + if(ifsuccess != EXE_RESULT_MEMORY) {
349 - - INITIAL_WAIT_FOR_MEM_CHECK)==WAIT_TIMEOUT)) {
349 + int based_time = (int)(t*1000) + 1 - INITIAL_WAIT_FOR_MEM_CHECK;
350 + bool major_timed_out = (WaitForSingleObject(pi.hProcess,
351 + based_time)==WAIT_TIMEOUT);
352 + if(major_timed_out) {
353 + // wait some more for user time.
354 + double time_used = get_process_time_usage(pi.hProcess);
355 + while(time_used <= t) {
356 + int iter_time = 100;
357 + if(t - time_used < 200)
358 + iter_time = 20;
359 + bool iter_timed_out = (WaitForSingleObject(pi.hProcess,
360 + iter_time)==WAIT_TIMEOUT);
361 + if(!iter_timed_out)
362 + break;
363 +
364 + time_used = get_process_time_usage(pi.hProcess);
365 + //printf("%lf\n",time_used);
366 + }
367 + ifsuccess = EXE_RESULT_TIMEOUT;
368 + }
369 + }
370 +
371 + if((ifsuccess == EXE_RESULT_MEMORY) || (ifsuccess == EXE_RESULT_TIMEOUT)) {
350 // Kill process, because (1) it used too much memory, or (2) time limit
372 // Kill process, because (1) it used too much memory, or (2) time limit
351 HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi.dwProcessId);
373 HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi.dwProcessId);
352
374
You need to be logged in to leave comments. Login now