From 0cebc6246b6f95c37e00a56fab6ead38da52c3d0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Jul 1995 17:32:17 +0000 Subject: (ports_manage_port_operations_multithread) [internal_demuxer]: Increment NREQTHREADS and TOTALTHREADS *before* forking newthread. [thread_function]: Don't increment NREQTHREADS and TOTALTHREADS here. Initialize NREQTHREADS and TOTALTHREADS in main body of function. --- libports/manage-multithread.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'libports/manage-multithread.c') diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c index 6b74f31d..5cb84b10 100644 --- a/libports/manage-multithread.c +++ b/libports/manage-multithread.c @@ -31,8 +31,8 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, int wire_cthreads, mach_port_t wire_threads) { - volatile int nreqthreads = 0; - volatile int totalthreads = 0; + volatile int nreqthreads; + volatile int totalthreads; spin_lock_t lock = SPIN_LOCK_INITIALIZER; auto void thread_function (int); @@ -54,7 +54,13 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, spin_unlock (&lock); if (spawn) - cthread_detach (cthread_fork ((cthread_fn_t) thread_function, 0)); + { + spin_lock (&lock); + totalthreads++; + nreqthreads++; + spin_unlock (&lock); + cthread_detach (cthread_fork ((cthread_fn_t) thread_function, 0)); + } pi = ports_lookup_port (bucket, inp->msgh_local_port, 0); ports_begin_rpc (pi, &link); @@ -80,11 +86,6 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, if (wire_cthreads) cthread_wire (); - spin_lock (&lock); - totalthreads++; - nreqthreads++; - spin_unlock (&lock); - if (master) timeout = global_timeout; else @@ -118,6 +119,8 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, } } + nreqthreads = 1; + totalthreads = 1; thread_function (1); } -- cgit v1.2.3