Wednesday, August 4, 2010

Parallel processing, yiha :)

So, you have some very high computation-demanding work to do? Furthermore, you also have some fancy server with 16 cores or more, all available for your sexy computations?
Cool, then you would LOVE the ppss.
What it does is that it can scan for you how many cores has the machine that runs ppss, and schedules list of processes to each of the cores.
For example, I have around 200 separate simulations to perform.
I downloaded ppss (no compilation necessary :) ), and just run it with specific command (help can be found on link above).

It reduced the running time of my simulations from 2 weeks to 2 days :)

Turn off the windows automatic updates

I am one of those people who don't like to turn off their PCs. Yea, really nice waste of energy, I know...

Usually work PC is the place when always something is running overnight, either some sort of calculations, parsing, simulations or any other nerdy stuff.

The most annoying part, when you work on windows, are the automatic updates. It can restart your PC by itself just to apply just installed updates. "§$%&%$ windows!

In order to disable such a stupid option,
Go to Start, Run "gpedit.msc" to bring up the group policy editor.
Then navigate to the folder

Local Computer Policy
->Computer Configuration
->Administrative Templates
->Windows Components
->Windows Update

There are two settings and both will work, so it's your choice. Either enable No auto-restart for schedule Automatic Updates installations or set Re-prompt for restart with scheduled installations to a long time interval, like 1440 minutes.

I prefer the first one :)

Thursday, May 13, 2010

Running a process that doesnt get killed on hangup

If you want to run a process on a server you are remotely connected to, without getting it disturbed if you close your SSH/telnet connection to a server, you should use command nohup

example:
nohup your_command &

& puts it into backgroung process, and nohup is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out.

Thursday, April 29, 2010

TOSSIM Python compiling problem

When you use TOSSIM in TinyOS, you come up to this error:

In function ‘void SWIG_Python_FixMethods(PyMethodDef*, swig_const_info*, swig_type_info**, swig_type_info**)’
error: invalid conversion from ‘const char*’ to ‘char*’

(overall there are two errors like this one)

First check whether the error can be solved using solution on TinyOS wiki website on
TOSSIM .

If even than, it doesn't work,
go to $TOSROOT/tos/lib/tossim and run ./generate-swig.bash
In my case, it shows you some warnings, but that is ok.
afterwards, it worked fine for me.

If you still have troubles, check also:
python and python-dev should be on the same version,
swig should be installed.

If all this didnt solve your problems, good luck finding it, and I hope you put the solution somewhere on internet as well.

Friday, March 26, 2010

Debugging QUALNET with GDB

Compiling QualNet with Debug Option
By default, the optimization option of the compiler is enabled in the Linux and Mac OS X Makefiles. When the optimization option is enabled, the compiler may optimize the program for better performance. However, for better source level debugging, the optimization option of the compiler should be disabled and the debug option should be enabled.
Perform following steps to recompile QualNet with the debug option enabled:
1. Go to QUALNET_HOME/main. Copy the makefile for your compiler to Makefile.
2.Edit Makefile as follows:
•Enable the DEBUG line by removing the ‘#’ character so it is displayed as:
DEBUG = -g
•Disable the OPT line by inserting a ‘#’ character at the beginning of the line so it is displayed as:
# OPT = -O3
3.Recompile QualNet by typing the following commands:
make clean
make

Running the Debugger
QualNet can be run from within debug tools such as gdb or dbx. Here, we use gdb as an example.
To run gdb, perform the following steps:
1. Open a command window. Go to the directory where the scenario to be debugged is located.
2.Load the QualNet executable into gdb by typing the following command (this assumes that QualNet is installed in /home/username/qualnet/5.0):
gdb /home/username/qualnet/5.0/bin/qualnet
3.From within the gdb environment, run your scenario in gdb by typing the following command (assuming the scenario configuration file is myscenario.config):
run myscenario.config
4.To exit gdb, type following command in gdb:
quit
Refer to gdb user manual for more information on how to debug a program in gdb.


Taken from https://www.scalable-networks.com/boards/viewtopic.php?f=47&t=4833&start=0


To get the value of the current variables use
print name_of_the_variable

To see where the function is called from:
backtrace

Friday, March 12, 2010

Regular expression for the functions

If you wanna have something like

int thisFunction(int a,
int b)
{


to be turned into


int thisFunction(int a,
int b)
{
printf("thisFunction Started");

You can search for functions using the following regular expression:

[[a-zA-Z0-9_-]+[\s]+]?[a-zA-Z0-9_-]+[*]?[\s]+[*]?([a-zA-Z0-9_-*]+)[\s]*\([\s]*([a-zA-Z0-9_-]+[\s]+[*]?[*]?[*]?[a-zA-Z0-9_-]+[,]?[\s]*)*\)[\s]*\{


update:

(static)?[\s]+(//inline//[\s]*)?[a-zA-Z0-9_-]+[*]?[*]?[\s]+([^\s\(]+)[\s]*\([^\)=]*\)[\s]*\{


Replace with:

\0 // \1 Started\r\nprintf("\1 Started");


update:

\0 // \3 Started\r\nprintf("\3 Started");

Saturday, February 20, 2010

"Reverse Engineering" in different programming languages?

A lot of engineers in one point of another needs to look through usually undocumented open source code, in order to modify/implement additional features. Using editor for bigger projects built in C/C++ (without OOP) can be unbelievably painful (my own experience). Two software that helped me a lot to reverse engineer my any source code are:

1) Doxygen: Creates nice documentation of all the functions in the project. It gives links to definition of each function, but more interesting is also can create call/caller graphs (for each function it gives graph of functions which it calls, and another graph of the function which call that function).
It is completely a freeware, and the graphs are done using the dot program.

2) Understand: the free trial version of this application (14 days) is very handy, and is a bit more powerful comparing to Doxygen.