summaryrefslogtreecommitdiff
path: root/libports
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-07-12 17:32:17 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-07-12 17:32:17 +0000
commit0cebc6246b6f95c37e00a56fab6ead38da52c3d0 (patch)
tree87cbec285b9c819550c53113b6c15fb6b97798ed /libports
parent502ebf0a7a4118ef6e52d9af4d8fe4b77ecf2ce5 (diff)
(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.
Diffstat (limited to 'libports')
-rw-r--r--libports/manage-multithread.c19
1 files changed, 11 insertions, 8 deletions
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);
}