pastglory1's blog

By pastglory1, 5 years ago, In English

Hello, I'm Exile_2k4.

Now, I really want to know if there is any tools (script, Windows CMD command, or something else) that can be used to limit execution time and memory consumption. In example, a CMD script that set the time limit of a process to 5 seconds and allows 256MB of memory (which is used by the task), and after 5 seconds, or exceeded the memory limit, if the task is still running, then kill it.

Just like what Codeforces, or any Online Judge do, but more portable.

Do you have any ideas ? My OS is Windows 10 (not Linux).

Thank you.

  • Vote: I like it
  • +16
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Use Windows Subsystem for Linux.

There are many tutorials for installation.

:)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    XD

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    could you give me some info about some resource monitor on linux like what I said above ? (I don't want complex installation.)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      link

      Just follow the simple instructions.

      And copy your code into the Linux Distribution's folder, and run it with

      timeout 5 {Your_Programs_Name}
      

      (Sorry, I don't know how to adjust with memory limit)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      But you can use command

      size {Your_Programs_Name}
      

      to see your program's static memory usage.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I am not familiar with Windows tools, but process-governor looks interesting.

      As FlameSlayer has mentioned, isolate is the answer for Linux. Building and installing are simple (install dependencies, make and make install) and it has been battle-tested in multiple IOI's. However, as it uses Linux-specific mechanisms it's not expected to run on Unix or native Windows (WSL may be a chance but I have not attempted).

      FYI, if not building a judge system with safety in mind, it is also possible to write a program to limit resource usage under Unix-like systems. If interested, look into the function setrlimit() (see the manual page, and there are also examples online).

      Hope it helps!

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

There are runners for Windows, but they require complex setup. You can see the VOJ's implementation here You need some Java and C++ skills, and you need to understand Chinese.

here is a compiled CMD version.

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

There is Run from PCMS2.

»
5 years ago, # |
  Vote: I like it -8 Vote: I do not like it

orz