From owner-freebsd-arch@FreeBSD.ORG Mon Aug 24 21:05:18 2009 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D21510656A8 for ; Mon, 24 Aug 2009 21:05:18 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout026.mac.com (asmtpout026.mac.com [17.148.16.101]) by mx1.freebsd.org (Postfix) with ESMTP id 0BE7C8FC2E for ; Mon, 24 Aug 2009 21:05:18 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii; format=flowed; delsp=yes Received: from macbook-pro.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp026.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KOW006K2D4SBL10@asmtp026.mac.com> for arch@FreeBSD.org; Mon, 24 Aug 2009 13:05:17 -0700 (PDT) From: Marcel Moolenaar In-reply-to: <20090824174050.GI2829@hoeg.nl> Date: Mon, 24 Aug 2009 13:05:16 -0700 Message-id: <2678DC6C-3E91-420A-B43D-02E0F1F853C5@mac.com> References: <20090824174050.GI2829@hoeg.nl> To: Ed Schouten X-Mailer: Apple Mail (2.1074) Cc: arch@FreeBSD.org Subject: Re: mtx_lock_do_what_i_mean() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2009 21:05:18 -0000 On Aug 24, 2009, at 10:40 AM, Ed Schouten wrote: > Hi all, > > As some of you may already know, I'm writing a console driver for > FreeBSD in my Perforce branch (newcons). What I don't like about > console > devices, but cannot be avoided, is that certain pieces of code need to > be protected by spinning mutex, instead of default mutexes. This is > because things like the terminal emulator need to be protected from > concurrent access, which is likely to happen when printf() by the > kernel > and a write() on a TTY by a userspace process happen at the same time. I would approach the problem differently: decouple printf() in the kernel from anything to which we have a TTY attached. Instead, look at printf() as a means to write to the message buffer only. Echoing things that go into the message buffer to the console becomes 1) optional (yay!), and 2) something you can do by going through the TTY layer (use a kthread or use a process [syslog]). Just a thought, -- Marcel Moolenaar xcllnt@mac.com