Question about Threads
Question about Threads
От:
"Leon Oosterwijk" <leon@isdn.net>
Дата:
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
Re: Question about Threads
От:
"Leon Oosterwijk" <leon@isdn.net>
Дата:
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;ibase_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;icheapest_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
> ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
>
Re: Question about Threads
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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? Yes, the backend code is not thread-safe. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073