当前线程由apache动态管理。
frompache的源代码中的worker.c: 根据需要启动线程。以下是启动工作线程的主要流程。
static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
startup_children(remaining_children_to_start); //server/mpm/worker/worker.c
if (make_child(ap_server_conf, i) < 0) { //server/mpm/worker/worker.c
child_main(slot); //server/mpm/worker/worker.c
rv = apr_thread_create(&start_thread_id, thread_attr, start_threads
rv = apr_thread_create(&threads[i], thread_attr, worker_thread, my_info, pchild);
当空闲线程> max_spare_threads,Apache会尽量减少孩子杀死进程/线程的线程备用,以减少空闲线程数。
if (idle_thread_count > max_spare_threads) {
/* Kill off one child */
ap_worker_pod_signal(pod, TRUE);
retained->idle_spawn_rate = 1;
}
内部apache管理这些子进程,并使用信号与子进程通信以根据需要调整线程。 所有线程管理ap_scoreboard_image->servers[i][j];