From fb8c531ddeef55c8581d3882bd1b1f501d980a30 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 15 Dec 2014 11:53:26 +0100 Subject: libports: avoid acquiring global lock in message dispatch * libports/interrupt-operation.c (ports_S_interrupt_operation): Update `cancel_threshold' using atomic operations. * libports/manage-multithread.c (internal_demuxer): Avoid taking the lock. * libports/ports.h (struct port_info): Mention that one needs atomic operations to access `cancel_threshold'. --- libports/manage-multithread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libports/manage-multithread.c') diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c index ad22991c..58814d2e 100644 --- a/libports/manage-multithread.c +++ b/libports/manage-multithread.c @@ -178,10 +178,12 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, } else { - pthread_mutex_lock (&_ports_lock); - if (inp->msgh_seqno < pi->cancel_threshold) + mach_port_seqno_t cancel_threshold = + __atomic_load_n (&pi->cancel_threshold, __ATOMIC_SEQ_CST); + + if (inp->msgh_seqno < cancel_threshold) hurd_thread_cancel (link.thread); - pthread_mutex_unlock (&_ports_lock); + status = demuxer (inp, outheadp); ports_end_rpc (pi, &link); } -- cgit v1.2.3