Linux Cluster with OpenMOSIX - Testing
Ok, so it's time to see some super-computing results, isn't it ? ;-)
I wrote this quick'n'dirty prg. simply to show the difference between a single machine
and 2 openmosix enabled machines. This program was running on a Celeron 433MHz - the
second machine in the cluster is a Pentium4 1.4GHz. The program simply creates two processes, so
that one process can migrate to another node. If this migration happens the time to complete both
processes is of course much lower than if both processes are handled on one machine.
The difference is quite obvious! ./test is running on machine #2 in the cluster (booted from our own CD):
Machine #1 disabled:
# ./test
MAIN: process ID is 171
MAIN: child process ID is 172
MAIN: started at 13:17:10
CHILD: process ID is 172
CHILD: started at 13:17:10
MAIN: stopped at 13:17:28
CHILD: stopped at 13:17:28
18 seconds to complete on machine #2 (433MHz).
Machine #1 enabled:
# ./test
MAIN: process ID is 169
MAIN: child process ID is 170
MAIN: started at 13:16:43
CHILD: process ID is 170
CHILD: started at 13:16:43
CHILD: stopped at 13:16:49
MAIN: stopped at 13:16:49
6(!) seconds to complete on both machines :-D
Sometimes the MAIN or CHILD process exits a few seconds earlier than the other.
The source code for the test-program:
test.c
// (C) 2004 captain.at - DWYW (Do What You Want) License ;-)
// compile with gcc -O2 -o test test.c
// simple test for openmosix linux cluster
// the prg. forks one child, does some useless calculation in
// the main process and child process and exits
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
struct tm *time_ptr;
time_t clock;
char tstr[20];
pid_t child_pid;
// printf ("MAIN: process ID is %d\n", (int) getpid ());
child_pid = fork ();
if (child_pid != 0) {
printf ("MAIN: process ID is %d\n", (int) getpid ());
printf ("MAIN: child process ID is %d\n", (int) child_pid);
clock = time(NULL);
time_ptr = localtime(&clock);
strftime(tstr, 20, "%H:%M:%S", time_ptr);
printf ("MAIN: started at %s\n", tstr);
int i = 0;
double x = 0.02323;
for (i=0;i<=1999999999;i++) {
x = x * 2;
}
clock = time(NULL);
time_ptr = localtime(&clock);
strftime(tstr, 20, "%H:%M:%S", time_ptr);
printf ("MAIN: stopped at %s\n", tstr);
} else {
printf ("CHILD: process ID is %d\n", (int) getpid ());
clock = time(NULL);
time_ptr = localtime(&clock);
strftime(tstr, 20, "%H:%M:%S", time_ptr);
printf ("CHILD: started at %s\n", tstr);
int i = 0;
double x = 0.02323;
for (i=0;i<=1999999999;i++) {
x = x * 2;
}
clock = time(NULL);
time_ptr = localtime(&clock);
strftime(tstr, 20, "%H:%M:%S", time_ptr);
printf ("CHILD: stopped at %s\n", tstr);
}
return 0;
}
Last-Modified: Sat, 04 Feb 2006 19:44:56 GMT