AgentM, 

The treads are joined back together by the master. I did try to debug, but
have to say I hard a hard time with it. I have tried to debug, but didn't
get very far. Debugging Threads is not my forte. :(  


Here is the code from :
/src/backend/optimizer/geqo/geqo_main.c

        for (i=0;i<thread_count;i++)
        {
                geqo_params[i].root = copyObject(root);
                geqo_params[i].number_of_rels = number_of_rels;
                geqo_params[i].initial_rels = copyObject(initial_rels);

                geqo_params[i].root->base_rel_list =
listCopy(root->base_rel_list);
                geqo_params[i].root->other_rel_list =
listCopy(root->other_rel_list);
                geqo_params[i].root->join_rel_list =
listCopy(root->join_rel_list);
                geqo_params[i].root->equi_key_list =
listCopy(root->equi_key_list);
                geqo_params[i].root->query_pathkeys =
listCopy(root->query_pathkeys);

                geqo_params[i].myid = i;

                pthread_create(&thread_list[i],
                        NULL,
                        (void *(*)(void *))  geqo_single , (void *)
&geqo_params[i]);
        }

        // join all thread and get results
        for (i=0;i<thread_count;i++)
        {
                elog(DEBUG1, "geqo: trying to join back thread %d", i);
                pthread_join(thread_list[i],(void *) results[i]);
                // sort results
                if (best_so_far == -1)
                {
                        elog(DEBUG1, "geqo: thread %d is first thread we
see", i);
                        best_so_far = i;
                }
                else
                {
                        if
(results[best_so_far]->cheapest_total_path->total_cost >
                                results[i]->cheapest_total_path->total_cost)
                        {
                                elog(DEBUG1, "geqo: thread %d is better than
thread %d ", i, best_so_far);
                                best_so_far = i;

                        }
                }


Leon

 

> -----Original Message-----
> From: AgentM [mailto:agentm@cmu.edu] 
> Sent: Saturday, November 08, 2003 4:01 PM
> To: Leon Oosterwijk
> Subject: Re: [HACKERS] Question about Threads
> 
> Are you using joined or detached pthreads? Have you tried debugging?
> 
> On Saturday, Nov 8, 2003, at 22:47 Europe/Berlin, Leon 
> Oosterwijk wrote:
> 
> > All,
> >
> > I'm working on a school project that involves genetic 
> algorithms. We 
> > thought
> > it would be neat to parralelize the genetic algorithm in 
> postgresql's 
> > query
> > optimiser. We used pthreads and are able to spawn threads 
> to deal with 
> > the
> > query optimization, however on exit of the thread the 
> postmaster blows 
> > up.
> > Before we get into details is there any obvious reason postgres 
> > doesn't like
> > to deal with threads?
> >
> > Thank you.
> >
> > Leon
> ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
> AgentM
> agentm@webopticon.com
> ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
> 


Sat, 8 Nov 2003 17:41:52 -0600
"Leon Oosterwijk" <leon@isdn.net>
Re: Question about Threads