Notes about Exectime facilities

Exectime overview

This year we will use (as an experiment) a new system for measuring execution time of contestants' programs. Instead of relying on the operating system for measuring the "execution time", we will be counting the number of assembly instructions executed on the processor.

For your convenience, we installed some components of our grading systems on the workstations to let you test your submission in an envionment as similar to the final grading system, as possible.

In short, the result got on your workstation should be very similar to what will be measured on our server.

SVIO Overview

SVIO is a library, which provides an API for reading input data and writing output data. It is tightly coupled with the supervisor and exectime facilities. Its main purpose is to move the overhead of parsing the input data from the evaluated program to the supervisor process. The description of SVIO library is here.

To compile your C/C++ program with SVIO, place

#include <svio.h>

and use the functions provided. Pascal users must place the following in the source

uses svio;

Note about the use of exectime and SVIO

Not all tasks are prepared to be judged using SVIO. You will be informed as to which tasks are judged using SVIO and exectime and which will be graded using classical methods.

What is installed on the workstations

To use the facilities of exectime and the SVIO library, you programs must be compiled with special compiler options and linked with a number of external libraries. A template Makefile containing rules for handling these issues can be found in /opt/svio/templates.

The Makefile is written in such a way, that the resulting executable, when run, will automatically run the required supervisor process. You can configure the behaviour of the supervisor using environment variables. For example:

export MEM_LIMIT=256000    # Memory limit: 256MB
export ET_LIMIT=100000000  # Execution time limit: 10 mln instructions
export ALLOW=1             # Allow all system calls; do not terminate the application
                           # when it uses forbidden system calls.
export OUT_LIMIT=50000000  # Output limit: 50MB

By default the memory limit is 256MB and the instructions limit is not enforced, but the regular execution time limit is 1000 seconds. By default forbidden syscalls are blocked.

An exaple login session:

[cpspc@cpspcstation ~]$ mkdir test                                              
[cpspc@cpspcstation ~]$ cd test                                                 
[cpspc@cpspcstation test]$ cp /opt/svio/templates/Makefile .                    
[cpspc@cpspcstation test]$ cat > a.c                                            
#include <svio.h>                                                               
int main() {                                                                    
        int a = read_int();                                                             
        write_int(a*a);                                                                 
        write_newline();                                                                
        return 0;
}                                                                               
[cpspc@cpspcstation test]$ make a                                               
gcc -static -W -Wall -g -I/opt/svio/include -o a a.c  /opt/svio/lib/libsvio.a 
/opt/svio/lib/libsvioparse.a /opt/svio/lib/libsvloader.a                          
[cpspc@cpspcstation test]$ ./a                                                  
555                                                                             
308025

0.0000M insns, 0.00 seconds, 3 system calls, 0.8MB memory                       
exit status: ok                                                                 
[cpspc@cpspcstation test]$

The default executable is unfortunately not suitable for debugging, because in fact the supervisor process is a simple debugger itself. To solve this problem, there is also an library providing emulation of the supervisor's SVIO functionality. To link your program with this library, use make program.d instead of make program. A sample interactive seesion log is below.

[cpspc@cpspcstation test]$ make a.d                                             
gcc -static -W -Wall -g -I/opt/svio/include -o a.d a.c  /opt/svio/lib/libsvio.a 
/opt/svio/lib/libsvioparse.a /opt/svio/lib/libsvloaderstub.a                    
[cpspc@cpspcstation test]$ gdb ./a.d                                            
GNU gdb 6.4                                                                     
Copyright 2005 Free Software Foundation, Inc.                                   
GDB is free software, covered by the GNU General Public License, and you are    
welcome to change it and/or distribute copies of it under certain conditions.   
Type "show copying" to see the conditions.                                      
There is absolutely no warranty for GDB.  Type "show warranty" for details.     
This GDB was configured as "i686-pld-linux"...Using host libthread_db library "/
lib/tls/libthread_db.so.1".

(gdb) run                                                                       
Starting program: /home/users/cpspc/test/a.d
libsvloader: no supervisor loader available, falling back                 
             to standalone mode.                                                
libsvio: using emulation                                                        
54                                                                              
2916                                                            

Program exited normally.                                                        
(gdb)

An example supervisor invocation:

[cpspc@cpspcstation test]$ export MEM_LIMIT=32000                               
[cpspc@cpspcstation test]$ export ET_LIMIT=1000000                              
[cpspc@cpspcstation test]$ supervisor -e ./a < a.in                             
SJudge Supervisor version 1.2                                                   
Copyright 2004-2006 (C) Szymon Acedanski

Program:        ./a                                                             
Memory limit:   32000 kB                                                        
ExecTime limit: 1 Mops                                                          
Output limit:   48828 kB                                                        
System time:    not counted

Syscall filter: enabled

144

0.0000M insns, 0.00 seconds, 7 system calls, 0.7MB memory                       
exit status: ok                                                                 
[cpspc@cpspcstation test]$

ExectimeNotes (last edited 2006-06-11 16:10:54 by accek)