On 22 September 2010 02:31, Qingpeng Niu <niuqingpeng@xxxxxxxxx> wrote: > Hi, > > I do a parallel open mp for which used shared data of g_hash_table. Program > do fine with the first parallel for loop but the third parallel for loop > program will stop there and never be entered. > g_thread_init(NULL); > .............. > #pragma omp parallel for private(i) shared(pdt_a) > for(i=0;i<psize;i++) > { > ............. > pdt_a[i].gh = g_hash_table_new(g_str_hash, > compare_strings); > ............ > } > #pragma omp parallel for private(i) shared(pdt_a,pit_a,lines,psize,nbuckets) > for(i=0;i<psize;i++) > { > for.... > lookup = g_hash_table_lookup(gh, input); > ..................... > g_hash_table_insert(gh, data, p_data); > ..................... > g_hash_table_replace(gh,strdup(input),p_data); > } > It is not clear from this code if the hash tables are shared between threads or if each thread has its own. If they are shared then you need to do the locking, from Gthread documentation : "After calling g_thread_init(), GLib is completely thread safe (all global data is automatically locked), but individual data structure instances are not automatically locked for performance reasons. So, for example you must coordinate accesses to the same GHashTable from multiple threads." If they are not shared then this is a question for the openmp ML not the glib ML. Cheers Lex > #pragma omp parallel for private(i) // this parallel for will not be > entered. Program will stop here and halt. > for(i=0;i<psize;i++) > -- > Qingpeng Niu > Department of Computer Science and Engineering at OSU > > _______________________________________________ > gtk-list mailing list > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list > > _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list