+ /*
+ * If all our workers are working hard, start some more to help out
+ * with things
+ */
+ begin_critical_section(S_THREAD_LIST);
+ /* FIXME: come up with a better way to dynamically alter the number of threads
+ * based on the system load
+ */
+// if ((CtdlThreadGetWorkers() < config.c_max_workers) && (CtdlThreadGetWorkers() < num_sessions))
+ // && (CtdlThreadLoadAvg < 90) )
+ if ((CtdlThreadGetWorkers() < config.c_max_workers) && (CtdlThreadWorkerAvg > 60) && (CtdlThreadLoadAvg < 90) )
+ {
+ end_critical_section(S_THREAD_LIST);
+ for (i=0; i<5 ; i++)
+// for (i=0; i< (num_sessions - CtdlThreadGetWorkers()) ; i++)
+// for (i=0; i< (10 - (55 - CtdlThreadWorkerAvg) / CtdlThreadWorkerAvg / CtdlThreadGetWorkers()) ; i++)
+ {
+ begin_critical_section(S_THREAD_LIST);
+ ctdl_internal_create_thread("Worker Thread",
+ CTDLTHREAD_BIGSTACK + CTDLTHREAD_WORKER,
+ worker_thread,
+ NULL
+ );
+ end_critical_section(S_THREAD_LIST);
+ }
+ }
+ else
+ end_critical_section(S_THREAD_LIST);