Changes between Version 16 and Version 17 of ModParrotArchitecture

11/29/08 18:51:12 (13 years ago)



  • ModParrotArchitecture

    v16 v17  
    6161Contexts are created at Apache startup during the configuration phase, when interpreters are needed to register various HLL modules and parse directives.  An interpreter is always started when a context is created. 
     63XXX Forking? 
    6465To maintain state, the same context must be used for all phases of a request, as it contains a reference to the interpreter.  When a context is needed, code should call {{{init_ctx(server_rec *s, conn_rec *c)}}}, which will return an available context from the pool.  If {{{c}}} is non-null, {{{init_ctx}}} will either return the context bound to that connection, or bind and return an available context if none is already bound.  Code in hooks that run before the pre-connection phase should pass a NULL connection. 
    169170=== Prefork MPM === 
     172In a non-threaded (prefork) MPM, each context pool in a process contains only one context, and cannot be grown or shrunk.  There may be multiple context pools depending on the virtual host configuration.  As each process is running at most one interpreter, there are no concurrency issues with this MPM. 
    171174=== Threaded MPM (e.g. worker) === 
     176In a threaded MPM such as the worker MPM, each context pool in a process contain multiple contexts and can be grown or shrunk dynamically.  Due to concurrency issues and the need to maintain state during all phases of a request, contexts are locked and bound to individual connections for the lifetime of those connections. 
     178Threads in Parrot are implemented using multiple interpreters (one interpreter per thread).  In Apache, each connection gets its own thread, and mod_parrot assigns a single context to that thread.  Therefore, as long as proper locks are maintained on the context pool and the contexts themselves, mod_parrot should be thread-safe with respect to a threaded MPM. 
     180mod_parrot uses one mutex, which is used to control access to the context pool: {{{apr_thread_mutex_t *ctx_pool_mutex;}}} (from src/context.c)