From owner-freebsd-questions@FreeBSD.ORG Tue Nov 14 23:11:03 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B4DE916A417 for ; Tue, 14 Nov 2006 23:11:03 +0000 (UTC) (envelope-from dwiest@vailsys.com) Received: from dprobd02.vailsys.com (dprobd02.vailsys.com [63.149.73.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E82243D53 for ; Tue, 14 Nov 2006 23:11:03 +0000 (GMT) (envelope-from dwiest@vailsys.com) Received: from dfsfbd06.vail (dfsfbd06.vail [192.168.129.190]) by dprobd02.vailsys.com (Postfix) with ESMTP id D156B8A5CB2; Tue, 14 Nov 2006 17:11:02 -0600 (CST) Received: from dfwdamian.vail (dfwdamian.vail [192.168.129.233]) by dfsfbd06.vail (Postfix) with ESMTP id 83FE0323E89; Tue, 14 Nov 2006 17:11:02 -0600 (CST) Received: from dfwdamian.vail (dwiest@localhost.vail [127.0.0.1]) by dfwdamian.vail (8.13.4/8.13.4) with ESMTP id kAENB2jX023328; Tue, 14 Nov 2006 17:11:02 -0600 (CST) Received: (from dwiest@localhost) by dfwdamian.vail (8.13.4/8.13.4/Submit) id kAENB2QN009778; Tue, 14 Nov 2006 17:11:02 -0600 (CST) X-Authentication-Warning: dfwdamian.vail: dwiest set sender to dwiest@vailsys.com using -f Date: Tue, 14 Nov 2006 17:11:02 -0600 From: Damian Wiest To: Robin Becker Message-ID: <20061114231102.GF20235@dfwdamian.vail> References: <4559DF39.7070506@chamonix.reportlab.co.uk> <20061114224652.GE20235@dfwdamian.vail> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061114224652.GE20235@dfwdamian.vail> User-Agent: Mutt/1.4.2i Cc: freebsd-questions@freebsd.org Subject: Re: sysv semaphores X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 23:11:03 -0000 On Tue, Nov 14, 2006 at 04:46:52PM -0600, Damian Wiest wrote: > On Tue, Nov 14, 2006 at 03:22:33PM +0000, Robin Becker wrote: > > I'm trying to test a python extension (POSH) that uses semaphores. When > > testing I get a run time error that indicates it requires too many > > semaphores. Is it possible to adjust the allowed number of semaphores > > without rebuilding the kernel? > > > > What are the costs of having semaphores ie are they memory/cpu intensive? > > -- > > Robin Becker > > You'll want to use either sysctl(8) to change the settings dynamically, or > use /etc/sysctl.conf to modify the settings permanently. I'm not sure if > there's a benefit to rolling a new kernel versus using sysctl.conf, or if > things even work that way anymore. > > # sysctl -a | grep seminfo > > kern.seminfo.semmni=10 # number of semaphore identifiers > kern.seminfo.semmns=60 # number of semaphores in system > kern.seminfo.semmnu=30 # number of undo structures in system > kern.seminfo.semmsl=60 # max number of semaphores per id > kern.seminfo.semopm=100 # max number of operations per semop call > kern.seminfo.semume=10 # max number of undo entries per process > kern.seminfo.semusz=100 # size in bytes of undo structure > kern.seminfo.semvmx=32767 # semaphore maximum value > kern.seminfo.semaem=16384 # adjust on exit max value > > Those comments are from /usr/include/sys/sem.h > > -Damian Sorry, I forgot to mention a few things. You should become familiar with ipcs(1) as it will allow you to query the current state of SysV IPC facilities. You'll probably find yourself manually deleting semaphores depending on how well that extension cleans up after itself during testing. IIRC, the kernel maintains some in-memory datastructures to keep track of semaphores. I believe increasing the maximum number of semaphores will take up a negligible amount of main memory. If you're interested, the "Design and Implementation of the 4.4 BSD Operating System" (ISBN # 0201549794) has great coverage of this stuff. -Damian