Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2009 19:40:50 +0200
From:      Ed Schouten <ed@80386.nl>
To:        arch@FreeBSD.org
Subject:   mtx_lock_do_what_i_mean()
Message-ID:  <20090824174050.GI2829@hoeg.nl>

next in thread | raw e-mail | index | archive | help

--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 <ed@80386.nl>
 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090824174050.GI2829>