Alan Knowles wrote: > Ok, had a play with this > updated copy on > http://docs.akbkhome.com/threads.tgz > > added a few of pthreads calls to TSRM.c > > did most of the testing without this abstraction layer - just to see if > I could get it to work. > > used php_exectute_script, rather than getting clever and copying the > function/class hashtables. > > results: > > It worked (with a few caveats - that are just a matter of getting to > know threading better)... > > some of the issues: > -if the child thread finishes before the main one - then the main one > needs to wait somehow..
Do you mean the other way around? > ** FIX = probably need to keep a count of threads that are running and > block at MSHUTDOWN on the main thread if stuff is still going. The thread variable needs to be a resource, or tracked somehow, by the parent thread. Each parent thread needs to wait for child threads before ending. > -the child thread needs to have the modules functions loaded before it > starts running really - otherwise you get intermitant 'functions not > available' if you dont dl() the module in the child thread. Fixed by loading in ini file. > ** FIX = I need to look at the pthreads equivalant for > tsrm_wait_event(thread.start_event,TSRM_INFINITE); will be.. this should > make sure that the main thread doesnt do anything while the main thread > is starting up.. I'm writing up rough equivelents to this, using pthread_cond_* functions. It will need work by someone using linux. > > - php_request_shutdown(NULL); calls the MSHUTDOWN for all modules - a > good example of where this cause trouble is the ext/standard/string.c > MSHUTDOWN, which has a static mutex that is freed. (and would be freed > twice when the main thread finishes) - > hence php_request_shutdown(), probably doesnt want to be called on a > thread completion.. > ** FIX = not sure? - does this need fixing or should we just ignore > php_request_shutdown...... This is because you are dl'ing the module. When you do that, *unfortunately*, the module is unloaded per request. In the module shutdown, we should wait for all threads that were started to shutdown. But the use of a global mutex should not be necessary once things are more developed. Loading from ini will fix this. Shane -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php