3 ms·
They don't. The program runs in your browser. It isn't their problem if it contains an infinite loop. If the page stops responding, you simply reload the page.
by compressedgas 7y ago
They don't. The program runs in your browser. It isn't their problem if it contains an infinite loop. If the page stops responding, you simply reload the page.
Programming contests use a check program that has a time limit on program execution.
- ili 7y agoBut 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.
- ili 7y agoSo how does that 'check program' works?