From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 3 03:27:20 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 0574D16A468 for ; Wed, 3 Oct 2007 03:27:20 +0000 (UTC) (envelope-from kip.macy@gmail.com) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.233]) by mx1.freebsd.org (Postfix) with ESMTP id BED9613C469 for ; Wed, 3 Oct 2007 03:27:19 +0000 (UTC) (envelope-from kip.macy@gmail.com) Received: by nz-out-0506.google.com with SMTP id l8so2782319nzf for ; Tue, 02 Oct 2007 20:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=BfPB0fSw1q3KAj48256BVQI+MqM2jQ0dNr9o7zAzVI0=; b=tiCwKFzT4hvrDbJ3YHxvyK2vfAkIcYo84NPLlP2hN7putqGsEEfnxR1qzIgUkjyjLgDr5TL8icPCJtrKee+5JeW1x+Wa9hHuVuhfW0cJjLF9v1reZl+tEBQvnaj5qgkpD5N0OXILXgvhDX3wFPfWDI7Ikdjo9X9pwqAmMyN3BHM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=G7fJK9ccTypqo3y3GmARxc6+mzmawSJfFodMMG8i6lylu8FjddQqLE5vizbNY5DoWlxCA+CoS6JvZaLQlr5DxDzdYG48kC7ocACucKcnWIkbGrgQDNF+bAir5hfug0uBWkaRhNq072+iSTw9r6MtWxbO1Xe9yMIFPifmw8k3Aus= Received: by 10.114.107.19 with SMTP id f19mr3274179wac.1191380422476; Tue, 02 Oct 2007 20:00:22 -0700 (PDT) Received: by 10.114.13.15 with HTTP; Tue, 2 Oct 2007 20:00:22 -0700 (PDT) Message-ID: Date: Tue, 2 Oct 2007 20:00:22 -0700 From: "Kip Macy" To: "Alfred Perlstein" In-Reply-To: <20071003025418.GN31826@elvis.mu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071003015231.GJ31826@elvis.mu.org> <20071003025418.GN31826@elvis.mu.org> Cc: Daniel Eischen , hackers@freebsd.org Subject: Re: 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 03:27:20 -0000 On 10/2/07, Alfred Perlstein wrote: > * Daniel Eischen [071002 19:46] wrote: > > On Tue, 2 Oct 2007, Alfred Perlstein wrote: > > > > >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. > > > > Setting the scheduling class to real-time and using SCHED_FIFO > > and adjusting the thread priority around the lock doesn't work? > > Too heavy weight, we want to basically have this sort of code > in userland: > > /* assume single threaded process for now */ > static int is_critical; > > > > atomic_mutex_lock(); /* implies ++is_critical */ > ...do stuff... > atomic_mutex_unlock(); /* implies --is_critical */ > > We don't want two or more syscalls per lock operation. :) I assume these processes are running as root? There is nothing to prevent the process from never dropping the lock. -Kip