NetRun Help
Logging In
If you don't yet have an account, or lost or don't trust
your randomly generated password, you can
reset your NetRun password here. NetRun passwords are long randomly generated strings. Sorry, there's currently no way to set a custom password!
The password reset script mails your randomly generated password
to your UAF email address. If you need to reset your UAF email
password, call the helpdesk at 474-6564. Once you have your NetRun
password,
you can log in to netrun.
How your Code Runs
NetRun's default mode is "Inside a function". In this
mode, the code you write becomes the center of a function named "foo";
like this:
int foo(void) {
YOUR CODE HERE
}
If you want to declare your own new functions, switch the Mode popup to
"Whole function (file)". NetRun's main program will still try
to call a function named "foo", so you have to name your top-level
function foo.
If you want to write your own complete main program, switch the Mode
popup to "Whole program (main)". None of the builtin NetRun code
will be included, and you can define any functions you like.
You'll need to #include "lib/inc.c" to get the builtin NetRun functions like print_int.
See also the Big List of NetRun Example Programs.
Saved Files
NetRun automatically saves everything you run under the "Run name:"
you enter. You can then go back to the saved version by clicking the
"Saved files:" link at the bottom of the page. If you use the same "Run
name" twice, it overwites the previous version. Be careful--this makes
debugging easier, but it also allows you to overwrite work!
Saved files with the same "prefix" are displayed together on one
line. NetRun defines a "prefix" as the whole run name up to the
first space, underscore or dot. So runs named "foo.bar",
"foo_you", and "foo is my name" will all show up under the line "foo:";
while "foobar" will get listed on its own line.
Header Files
A selection of useful header files are automatically included by NetRun. Currently, NetRun automatically includes:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include "lib/inc.h"
The only NetRun-specific header is "lib/inc.h". The functions in lib/inc.h are documented below.
If you need to include additional headers, just switch to Whole
Function or Whole Program mode, and write the appropriate #include.
Keyboard Shortcuts
NetRun uses the Ace editor keyboard shortcuts in the edit area.
Ctrl-Shift-R will run it on most browsers.
Builtin NetRun Functions
There are a bunch of handy functions built in to NetRun. You
can see how they work if you check the project/lib/inc.c file inside
"Download this file as a .tar archive". In no particular order,
the functions are:
- long read_input(void);
Reads one long integer from the standard input. Hit the "Input"
checkbox to get the input box, and type integers into this box.
This function accepts any C/C++ formatted integer, so 0x10 is actually
treated as hex. The function will complain if it can't parse an
integer.
Example: long i=read_input(); // i now contains value read from "Input data" box.
- float read_float(void);
Reads one floating point number from the standard input.
Example: float f=read_float(); // f now contains value read from "Input data" box.
- int read_string(const char *dest);
Read a C string of up to 100 characters from standard input.
Example: char str[100]; read_string(str);
- void print_int(int i);
Print out an integer, in both decimal and hexadecimal.
Example: print_int(0xff); // Prints 255 and 0xff.
- void print_long(long i);
Print out a long (64-bit) integer, in both decimal and hexadecimal.
Example: print_long(0x123456789abcdefLL); // Prints 64-bit constant.
- void print_float(float f);
Print out a 32-bit floating point number. This is especially useful
from assembly language.
Example: print_float(1.234); // Prints a float.
- double time_in_seconds(void);
Returns the current wall-clock time, in seconds. The timer
resolution is milliseconds on UNIX machines, but only 60ms on Windows.
Example: double t=time_in_seconds(); // t now contains the wall-clock time
- double time_function(timeable_fn fn);
Returns the number of seconds taken by one execution of this user
function. The function is run many times, in order to stay
accurate even with coarse timers. A "timeable_fn" is just a
function that takes no arguments and returns an int.
Example: double t=time_function(bar); // bar takes t seconds per call
- void print_time(const char *fnName,timeable_fn fn);
Prints
out the speed of this function, in time per call. "fnName" is
just used for the printout. The "Time" checkbox (under "Actions")
actually calls print_time on the central foo function, although it
always prints foo's time in nanoseconds.
Example: print_time("Bar function takes",bar); // Prints time taken by bar function
- int iarray_print(int *arr,int n);
Print out the entries in this n-element int (DWORD) array. Will only
print selected values for arrays with more than 10 elements.
Always returns n.
Example: int arr[7]=...; iarray_print(arr,7);
- int larray_print(long *arr,long n);
Print out the entries in this n-element long (QWORD) array. Will only
print selected values for arrays with more than 10 elements.
Always returns n.
Example: long arr[7]=...; larray_print(arr,7);
- int farray_print(float *arr,int n);
Print out the entries in this n-element float array. Will only
print selected values for arrays with more than 10 elements.
Always returns n.
Example: float arr[7]=...; farray_print(arr,7);
- void farray_fill(float *f,int n,float tol);
Fills up this array with more or less random floating-point
values. Always puts a fixed value in f[n]. The values will
range from 0 to 255*tol.
Example: float f[11]; farray_fill(f,10,1.0); // Fills up f[0..10] with random values.
- int farray_checksum(float *f,int n,float tol);
Computes the checksum of the floating-point values in this array. Checks the fixed value in f[n] put there by farray_fill.
Example: return farray_checksum(f,10,1.0); // Returns a 16-bit
checksum of the values in the array.
- void dump_ascii(void *ptr,long bits);
Print out the data at this pointer as ASCII byte values.
Keeps printing for the specified number of bits.
Example: const char *p="yo"; dump_ascii(p,16);
- void dump_hex(void *ptr,long bits);
Print out the data at this pointer as hexadecimal byte values.
Keeps printing for the specified number of bits.
Example: long x=3; dump_hex(&x,64);
- void dump_binary(void *ptr,long bits);
Print out the data at this pointer as binary bit values.
Keeps printing for the specified number of bits.
Example: long x=3; dump_binary(&x,64);
- void cat(const char *fileName);
Print out the contents of the given file. Automatically detects binary
files, and switches to hex output. Only outputs the first 1000 characters
of the file.
Example: cat("code.exe"); // prints the compiled executable
All these functions are accessible from both C and C++, and they work the same way in both languages.
Debugging in Assembly Language
The main program prints out the value returned from the "foo"
function you write, and x86 functions return their value in register rax,
so you can see what's in register rax by just returning--it'll get printed out.
At the moment, there's no easy way to see what's in all the registers
other than intentionally crashing, like doing a read-from-NULL:
mov rax,[0]
You get an informative printout when you
crash because NetRun registers a whole set of signal handlers (for
segmentation fault, floating point exception, illegal instruction,
etc.). If you're interested in how this works, use the "Download
this file as a .tar archive" link and read project/lib/signal.c.
Reading Input in Assembly
- Say "extern read_input" and "call read_input" as the FIRST TWO LINES in your assembly
program.
This function may trash (i.e., change) all other registers, so be sure
to call it before doing anything else! read_input, like any
function, returns its value in the rax register.
- Use rax as input to whatever computation you need to do.
- In the NetRun GUI, click "Input" checkbox to display the input
data edit box.
- Enter the program's input data--just numbers--in the input data edit
box.
- Hit "Run!". The program will read the input you've typed
in.
You can call "read_input" from C or C++, too--it takes no parameters, and
returns the integer read in.
NetRun Output Images
NetRun automatically displays an image if your program writes
a image file named "out.ppm", stored in the PPM image format.
Here's a complete out.ppm example program.
NetRun Hardware
The NetRun "P4" machine is an Intel Pentium 4 running at 2.8GHz. Hyperthreading is enabled, with
two CPU frontends sharing the same arithmetic backend. The L2 cache is 1024KB.
Security in NetRun and Terms of Use
You are welcome to do any of the following using NetRun!
- Run performance experiments, debug code, and explore new
languages and architectures.
- Solve homework assignments for any course.
- Try out example code from the lecture notes.
The main NetRun CGI is a Perl script. You're welcome to download that Perl script, using the "Download all saved files as a big .tar.gz archive"
link. This Perl script runs in taint mode, and uses regular
expressions to check for dangerous characters in the input data.
It has extensive logging, and everything you run is marked with your
username. This means you should not attempt to hack into
NetRun itself, or use NetRun to attack other machines.
You are not allowed to: share your NetRun account;
denial-of-service or hack into NetRun; use NetRun to
attack other machines; or use NetRun for any illegal, commercial,
or partisan political purpose. Keep in mind the surprisingly
open-ended Alaska statute AS11.46.740
makes "criminal use of a computer" a class C felony.
Your executable programs run with a variety of restrictions, enforced by the kernel:
- You cannot run for more than 2 seconds, or NetRun will print "Killing program--ran too long!".
- You cannot use more than 1 GB of memory, or further allocations just fail.
- Your program is running in a "chroot" jail, so you can't access any files on the machine.
- Your program runs as a nobody user. You have no rights.
To go beyond these restrictions, download a tar file of your
project, and run it on your own machine!
Changes:
- Upgraded to 64-bit rax in examples, from eax (2024-09-18)
- Removed 'using namespace std;', added using declarations for cin and cout only. (2019-03-28)
- ACE editor support (2016-02-05, thanks to Noah Betzen)
- Disqus comments for homeworks after OK! (2014-08-22)
- foo can take or return long, string, etc. (2014-08-20)
- Keyboard shortcut: Alt-R runs it! (2012-09-28, thanks to Ben White)
O.
Lawlor, lawlor@alaska.edu
CS, UAF