From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 5 19:00:31 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAC4F1065720; Sun, 5 Feb 2012 19:00:31 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id CC4108FC33; Sun, 5 Feb 2012 19:00:23 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 62BE91DEDDB; Sun, 5 Feb 2012 20:00:22 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 49E9428468; Sun, 5 Feb 2012 20:00:22 +0100 (CET) Date: Sun, 5 Feb 2012 20:00:22 +0100 From: Jilles Tjoelker To: Daniel Eischen Message-ID: <20120205190022.GC57421@stack.nl> References: <201201110806.30620.jhb@freebsd.org> <5D37298B-9D68-4F0F-8AAB-E8F2DBB9D9C3@transactionware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Garrett Cooper , freebsd-hackers@freebsd.org, Ivan Voras , Xin LI , Jan Mikkelsen , davidxu@freebsd.org Subject: Re: sem(4) lockup in python? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Feb 2012 19:00:32 -0000 On Sun, Feb 05, 2012 at 01:32:42PM -0500, Daniel Eischen wrote: > On Sun, 5 Feb 2012, Ivan Voras wrote: > > On 5 February 2012 11:44, Garrett Cooper wrote: > >>    'make MAKE_JOBS_NUMBER=1' is the workground used right now.. > > David Xu suggested that it is a bug in Python - it doesn't set > > process-shared attribute when it calls sem_init(), but i've tried > > patching it (replacing the port patchfile file the one I've attached) > > and I still get the hang. > I don't understand how process shared semaphores can work. Perhaps > I'm dumb and ignorant, but a sem_id_t is an allocated struct. The > actual kernel sem_id is inside the struct. Isn't this the same > reason pthread_mutex_t and pthread_cond_t cannot be process-shared? That's how the old implementation works. It does not support process-shared semaphores although they may happen to work in some specific cases. However, in 9.0, sem_t works differently and contains the actual lock word directly, so that process-shared semaphores work. The implementation is in lib/libc/gen/sem_new.c. The pshared flag to sem_init() is not a no-op because it tells the kernel to allow for use from multiple processes. Note that the old implementation is still present as well, for compatibility with old binaries. -- Jilles Tjoelker