Changes between Version 16 and Version 17 of ModParrotArchitecture
- Timestamp:
- 11/29/08 18:51:12 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ModParrotArchitecture
v16 v17 61 61 Contexts 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. 62 62 63 XXX Forking? 63 64 64 65 To 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. … … 169 170 === Prefork MPM === 170 171 172 In 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. 173 171 174 === Threaded MPM (e.g. worker) === 175 176 In 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. 177 178 Threads 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. 179 180 mod_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)