From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 3 02:19:10 2007 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E44B16A41A for ; Wed, 3 Oct 2007 02:19:10 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 5CAFF13C469 for ; Wed, 3 Oct 2007 02:19:10 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 1432E1A4D7E; Tue, 2 Oct 2007 18:52:31 -0700 (PDT) Date: Tue, 2 Oct 2007 18:52:31 -0700 From: Alfred Perlstein To: hackers@freebsd.org Message-ID: <20071003015231.GJ31826@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: Critical Sections for userland. 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: Wed, 03 Oct 2007 02:19:10 -0000 Hi guys, we need critical sections for userland here. This is basically to avoid a process being switched out while holding a user level spinlock. The way I envisioned doing this was as follows: 1) syscall that sets a pointer in the struct thread. 2) user mlocks that page. 3) when scheduler goes to switch out a process due to quantum it checks this pointer, if set it will give the process more time to run and not switch it out. (*) 4) the load would seem to have to be non-faulting. So my questions are: 1) Where would be a good place to add this code in the scheduler and how? 2) How does one do a read/write to userland address, but if the access would fault, then return an error rather than trap? I'm quite sure the scheduling decisions would be made inside of the timer interrupt, (am I right?), and hence would not be allowed to fault in pages. (*) Note, we will implement limits to this so that a haywire application is not able to be "critical" forever. Any help would be appreciated. -- - Alfred Perlstein