Re: Simple Program with pthreads(with source) + openssi stable 1.2.2

John Hughes <[email protected]> Thu, 09 Apr 2009 13:34:31 +0200
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
Cleir Araujo wrote:
>  
> Hello developers,
>  
> when i try to exec a simple program with pthreads, the
> following message appears: "Cannot move process 775543 - 775543 is a 
> system process".
One strange thing about your test process is that it starts all of the 
worker threads then calls pthread_exit(NULL), so the main thread is 
defunct while the others are runnning:

john@f:~$ bash-ll
john@f:~$ clusternode_num
6
john@f:~$ where_pid $$
6
john@f:~$ ./calc >/dev/null & 
[1] 437832
john@f:~$ ps -fp 437832
UID             PID       PPID  C STIME TTY          TIME CMD
john         437832     437810  0 13:37 pts/7    00:00:08 [calc] <defunct>

If I "fix" it so the main thread waits for the workers (even though they 
will never finish) and then try migrating it I get:

add_thread_group:Cannot move process 438181 (calc) - cannot find all shares
add_thread_group: group(438181)/share imbalance 4/1

(This is on my 2.6.14 system, so it may have bugs that the standard 
2.6.11 based system doesn't have).

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
pthread-test.c (text/x-csrc, 793 B)
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_THREADS     3
void *LancaThread(void *threadid)
{
   long tid;
   tid = (long)threadid;
   printf("Spaning thread #%ld! %-10.2f\n", tid);
   while (1)
    printf ("Calculating: %f\n",sqrt (rand ()));
    pthread_exit(NULL);
    return 0;
}
int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t=0;t<NUM_THREADS;t++){
   rc = pthread_create(&threads[t], NULL, LancaThread, (void *)t);
  if (rc){
    printf("ERROR to spawn thread pthread_create() return: %d\n", rc);
    exit(-1);
    }
  }
for(t=0;t<NUM_THREADS;t++){
   rc = pthread_join(threads[t], NULL);
  if (rc){
    printf("ERROR pthread_join() return: %d\n", rc);
    exit(-1);
    }
  }
pthread_exit(NULL);
}