From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 30 00:36:14 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CE26B16A401 for ; Fri, 30 Mar 2007 00:36:14 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 8C66C13C44B for ; Fri, 30 Mar 2007 00:36:14 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by an-out-0708.google.com with SMTP id c24so334762ana for ; Thu, 29 Mar 2007 17:36:14 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=Dazh06cIGZdqD1upj50ow7bK8dSKQRENb+goVPzONAsLgeZWzoulFCE30pIo+dFvrvvFM+ChruiqqSNnoLHYKn2LoC4/U5CJLQUFB75/M04IWfEBLgOWVyA5a2sBTQYRh5O7SmhqPexTw+T1mFC2rNxY+J7Dh+woADSgT0eeXSA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ergEfu5KwtrjD15ntqB8lcpRwih//GU9EOSsnwZkKIuatu8N+STdCbW51IDyM3h/CySbdln9eP1aecgvEBSoKstiJyhaAxW+3EFptl9UF0pGCcD0epMWyemTiDjiGjMwX8U+UZXoGgGz5Zj6ebXUfKk0xnA5mXz1kgq5J46GTTU= Received: by 10.100.44.13 with SMTP id r13mr926412anr.1175213233253; Thu, 29 Mar 2007 17:07:13 -0700 (PDT) Received: by 10.100.191.1 with HTTP; Thu, 29 Mar 2007 17:07:13 -0700 (PDT) Message-ID: <3bbf2fe10703291707j48c5b9cmdf9b08c8c60dd0ef@mail.gmail.com> Date: Fri, 30 Mar 2007 02:07:13 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Robert Watson" In-Reply-To: <20070328102027.T1185@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070328082620.GA1052@dwpc.dwlabs.ca> <20070328102027.T1185@fledge.watson.org> X-Google-Sender-Auth: 90d9c262ceb6c308 Cc: freebsd-hackers@freebsd.org, Duane Whitty Subject: Re: Locking etc. (Long, boring, redundant, newbie questions) 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: Fri, 30 Mar 2007 00:36:14 -0000 2007/3/28, Robert Watson : > Pretty much. We disable interrupts for the following reason: as spin mutexes > may be acquired in fast interrupt handlers, they may be running on the stack > of an existing thread, which may also hold locks. As such, we can't allow the > fast handler to acquire any locks that are either already held by the thread, > or that might violate the lock order. By restricting fast interrupt handlers > to holding only spin locks, and by making spin locks disable interrupts, we > prevent that deadlock scenario. Really, avoid lock ordering violation is one of the motivations that don't allow usage of sleepable locks in fast handlers. We disable interrupts for spin-locks mainly in order to avoid to be preempted by an interrupt thread (or, however, an higher priority thread) that can contest on the spin-lock we are holding and so can cause a deadlock since we will never have a chance to be executed again (there will always be an attempt to execute first the higher priority thread that cannot start again). You can make this concept more general if you mind what you first stated -- that spinning should not be longer than rr time quantum. If you get preempted by another thread this won't certainly happen however. For this reason, you are not allowed to perform any sort of sleeping (as bounded or unbounded) while holding a spin-lock. Attilio -- Peace can only be achieved by understanding - A. Einstein