From owner-freebsd-current@FreeBSD.ORG Wed May 10 07:45:56 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 51CDC16A408; Wed, 10 May 2006 07:45:56 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail28.syd.optusnet.com.au (mail28.syd.optusnet.com.au [211.29.133.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE95D43D5E; Wed, 10 May 2006 07:45:51 +0000 (GMT) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail28.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k4A7jmfs026103 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 10 May 2006 17:45:49 +1000 Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.13.6/8.13.6) with ESMTP id k4A7jmCG000907; Wed, 10 May 2006 17:45:48 +1000 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.13.6/8.13.6/Submit) id k4A7jmIO000906; Wed, 10 May 2006 17:45:48 +1000 (EST) (envelope-from peter) Date: Wed, 10 May 2006 17:45:47 +1000 From: Peter Jeremy To: David Xu Message-ID: <20060510074547.GA700@turion.vk2pj.dyndns.org> Mail-Followup-To: Peter Jeremy , David Xu , Daniel Eischen , current@freebsd.org References: <20060506150622.C17611@fledge.watson.org> <20060509181302.GD3636@eucla.lemis.com> <20060509182330.GB92714@xor.obsecurity.org> <200605100726.28243.davidxu@freebsd.org> <44613469.2050000@freebsd.org> <4461522D.9060405@freebsd.org> <446165B5.7030006@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <446165B5.7030006@freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.11 Cc: Daniel Eischen , current@freebsd.org Subject: Re: Fine-grained locking for POSIX local sockets (UNIX domain sockets) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 May 2006 07:45:56 -0000 SunOS 4 (not sure about SunOS 5) exports a per-CPU page that includes a high-resolution timer amongst other things. On Wed, 10 May 2006, David Xu wrote: >One of the problems to implement it is that atomic operations, >if there are multiple integer needs to be updated by kernel, >userland maybe gets an inconsistent result, the way to avoid the >problem is using two generation numbers. A lot of the need for atomic operations goes away if the page (or whatever) refers to the current CPU - the page is either being updated by the current CPU in kernel mode or read by the current CPU in userland. The page won't be updated/accessed by other CPUs. You still need to update the base time and TSC (or whatever) count in a way that looks atomic to userland but I suspect the kernel could achieve this by twiddling the code transparently to userland (eg there are two copies of the base/count and the kernel flips a pointer between then). On Wed, 2006-May-10 12:01:57 +0800, David Xu wrote: >Daniel Eischen wrote: >>Can you not make a simple pseudo device driver and mmap the page? >> >mmap is fine if you don't care binary compatible, exporting a kernel >page which can be executed by userland is more flexible, kernel can >change it freely without having to change libc. These aren't mutually exclusive - .so's are mmap'd. All libc needs to do is mmap a page from a pseudo device and execute a function in it. Either the function could be at a magic address or the pseudo device could simulate a shared object so you just dlopen() the device. -- Peter Jeremy