3 ms·
But if you check Ideone.com and write a code like this: while(true){} the page loads but the ide says time limit exceeded after 5 seconds and stops the execut
by ili 7y ago
But if you check Ideone.com and write a code like this:
while(true){}
the page loads but the ide says time limit exceeded after 5 seconds and stops the execution. Now, how do you do that?
- brudgers 7y agoThe user program containing the while-loop could be executed with a system call as: executeUserProgram(userProgram, timeout=5)... alternatively, the server on which the user program runs could monitor user processes and terminate any process using excessive CPU time. Both approaches look for the effects of an infinite loop instead of the program logic of an infinite loop. Which makes sense since logical analysis for infinite loops is the Halting Problem and NP-Hard.
- ili 7y agoyes that is what i want. is executeUserProgram() a system call? how do i implement this in windows. I am thinking of forking a process and then kill the other process after certain amount of time. will it work?
- brudgers 7y agoexecuteUserProgram() Is an abstraction. I made up the name to explain how the behavior might be implemented in the abstract. Implementing the abstraction in a way appropriate for an actual program is software engineering based on the actual program's actual constraints.