Sunday, June 28, 2009

Soft realtime

Recently we wanted to try out some hard real time stuff. When we attempted it, the results were not satisfactory. Today, I just tried a program to see how a soft real time program performs against a normal program.
(Notice the use of SCHED_FIFO and a priority


#include <stdio.h>
#include <sched.h>
#include <sys/time.h>

int main()
{

int retval=-1;
struct sched_param sp;
struct timeval tv;
int old=0;


#if defined(SFT_RLT)

sp.sched_priority=20;
retval=sched_setscheduler(0,SCHED_FIFO,&sp);
printf("Ret= %d\n",retval);

#endif

while(1)
{

gettimeofday(&tv,NULL);
old=(tv.tv_usec-old)<0?1000*1000+tv.tv_usec-old:tv.tv_usec-old;
printf("%u %u %u \n",tv.tv_sec, tv.tv_usec,old);
old=tv.tv_usec;
usleep(1000*200);

}

return 0;
}


I compiled two binaries from this

gcc -DSFT_RLT rt.c -o rt
gcc rt.c -o nrt

As one can easily see, the first one is a soft realtime program and the second is a normal program. I ran these programs under two scenarios. One, when the system was relatively free; two, when the system was loaded. This is what I did and observed.

Normal scenario (X, FVWM, Terminal, bittorrent and Firefox)



./rt./nrt

1246142672 137029 200069
1246142672 337101 200072
1246142672 537171 200070
1246142672 737242 200071
1246142672 937312 200070
1246142673 137344 200032
1246142673 337413 200069
1246142673 537486 200073
1246142673 737557 200071
1246142673 937627 200070

1246142672 004983 200072
1246142672 205055 200072
1246142672 405127 200072
1246142672 605199 200072
1246142672 805265 200066
1246142673 005331 200066
1246142673 205402 200071
1246142673 405538 200136
1246142673 605604 200066
1246142673 805668 200064

Then I tried running the same under loaded condition. (Just played a movie using mplayer. The other processes which were earlier running were running now also)



./rt./nrt

1246146025 832916 200046
1246146026 032951 200035
1246146026 233010 200059
1246146026 433064 200054
1246146026 633097 200033
1246146026 833150 200053
1246146027 033203 200053
1246146027 233255 200052
1246146027 433286 200031
1246146027 633317 200031
1246146027 833368 200051

1246146025 803540 200145
1246146026 003647 200107
1246146026 203734 200087
1246146026 403823 200089
1246146026 603918 200095
1246146026 804006 200088
1246146027 004127 200121
1246146027 204204 200077
1246146027 404257 200053
1246146027 604314 200057
1246146027 804368 200054

I guess the difference in result is noticeable.This is easier to achieve compared to hard rt, since there is no kernel patches needed. When we make a break through with hard rt, I will post again

Saturday, June 13, 2009

Migrating phpBB2.0.13 on RH9 to phpBB3 on F11

I am doing this for my division in SISO. I am typing in stuff as I do it.

1. Tar the old BB directory
tar cvjf bb.tbz phpBB2
(Replace phpBB2 with the name of the folder containing your earlier phpBB2 installation)
2. Get the data from the mysql table
mysqldump -u root -p --databases div_dbase > div.sql
(replace 'root' with any other admin name who has full permission and 'div_dbase' with the name of database used by your old installation)
3. Scp these files to your new machine.
(It is expected that you have mysql, php-mysql, apache etc are installed and turned on in the new machine)
4. re-insert the sql data
mysql -u root -p < div.sql
Note 1: If you are a mysql pro and want to take some trouble configuring a new user at your old machine who can access mysql db on the old machine from the new one, this step might not be needed
Note 2: The mysql that comes with F11 does not consider --- as a comment. However the old sql dump will have a line like -------------. Just edit it and make it -- --------------- (Note the space after two hyphens).
5. Untar the old BB2 installation folder into /var/www/html. Rename if necessary (You may want to use the same folder name for BB3)
6. Download and install BB3
7. Make the directories of BB3 owned by apache user
chown -R apache.apache forum
(Where 'forum' is the folder containing the BB3 installation)
8. Click on the convert tab. Enter necessary information. Assuming you followed step 4, you will have to enter: new root password, location of old BB2 wrt to new BB3 (If you were strictly sticking to these instructions, it will be ../) and the table prefix for the old db (phpbb_ is the default)

Thats it. Just click the convert button and you will have the new BB ready in a few minutes!

Thursday, June 11, 2009

Fedora 11

Downloaded at office for creating a website. Installed on an old machine. Did not use it much. On startup itself smart came and told that my disk is failing (Nice feature. Don't know if it was part of F10). I am downloading this at my house. But that will arrive only tomorrow. The most noticeable thing was bootup. Though, it did not happen with in 20 sec on my machine (mostly because of dhcp, I guess), the way the boot screen was transformed to initial login screen was really nice. More and screenshots after I get it installed at home.