From owner-freebsd-arch@FreeBSD.ORG Mon Aug 24 17:40:51 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 A5652106568B for ; Mon, 24 Aug 2009 17:40:51 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 46D718FC1A for ; Mon, 24 Aug 2009 17:40:51 +0000 (UTC) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 4C62F1CD58; Mon, 24 Aug 2009 19:40:50 +0200 (CEST) Date: Mon, 24 Aug 2009 19:40:50 +0200 From: Ed Schouten To: arch@FreeBSD.org Message-ID: <20090824174050.GI2829@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8/UBlNHSEJa6utmr" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: 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 17:40:51 -0000 --8/UBlNHSEJa6utmr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.=20 It's not like the spin locks are held for an insane amount of time, but still, especially when doing things like scrolling the screen buffer, I think using default mutexes would be a lot better. I was thinking, in theory I'd only need to lock the first window of my console device instances with spin locks, because the other windows will never interact with the kernel message/debug console. I was thinking about locking the mutexes and using their lock classes to call the appropriate lock routine, but looking at the source, something tells me this won't work: | void | lock_spin(struct lock_object *lock, int how) | { |=20 | panic("spin locks can only use msleep_spin"); | } So basically I'm sending this message to ask what I should do here. Is there a more elegant way to solve this? --=20 Ed Schouten WWW: http://80386.nl/ --8/UBlNHSEJa6utmr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkqS0KIACgkQ52SDGA2eCwVvtgCfTSCbW6Dr2V3QbocPgoClJirk ktkAn18/s6RGmrryHwaZneG45ddBwE0w =6W9J -----END PGP SIGNATURE----- --8/UBlNHSEJa6utmr--