From owner-freebsd-arch@FreeBSD.ORG Tue Jul 9 16:12:28 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DED5E80C; Tue, 9 Jul 2013 16:12:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id B97931AA8; Tue, 9 Jul 2013 16:12:28 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AF0A3B94A; Tue, 9 Jul 2013 12:12:25 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: General purpose library for name/value pairs. Date: Tue, 9 Jul 2013 10:39:26 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <20130704215329.GG1402@garage.freebsd.pl> <20130708213351.GB1405@garage.freebsd.pl> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201307091039.26835.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 09 Jul 2013 12:12:25 -0400 (EDT) Cc: "Jordan K. Hubbard" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 16:12:28 -0000 On Monday, July 08, 2013 6:09:40 pm Jordan K. Hubbard wrote: > > FYI, FreeBSD can pass shared memory as file descriptors, see SHM_ANON in > > shm_open(2). > > OS X supports this as well. The reason we make it an explicit type is for two reasons. One is lifecycle management - you can't just close a fd representing a shared memory segment and have all the right things happen on last close (the segment itself won't be GC'd). The second reason is that both ends want a fd in one case and an address in the other and it would be weird to mix and match metaphors just because the transport wanted to canonicalize everything into fds. I'll only speak to the GC point. For anonymous shm's (SHM_ANON), the segment is in fact GC'd on last close as there is no name to hold a reference to it. Note that this is an extension to the POSIX API. These anonymous objects are in fact quite useful for creating arbitrary shms, and we even have an API for mapping them into KVA so that they can be great tools for doing shared memory IPC between userland and kernel. -- John Baldwin