From: beto@ncube.com beto@ncube.com
Subject: spin-locks problem
Date: Fri, 9 May 1997 18:30:28 -0700 [thread overview]
Message-ID: <19970510013028.-QZTMy2Rm4tPJWAl6vS8khzatHb-G68d1bO4TiIid-w@z> (raw)
Here is the problem which dhog mentioned:
long
bitread(Chan *c, void *va, long n, ulong offset)
{
uchar *p, *q;
long miny, maxy, t, x, y;
ulong l, nw, ws, rv, gv, bv;
int off, j;
Fontchar *i;
GBitmap *src;
BSubfont *s;
static int map[8] = {0, 4, 2, 6, 1, 5, 3, 7 };
if(!conf.monitor)
error(Egreg);
if(c->qid.path & CHDIR)
return devdirread(c, va, n, bitdir, NBIT, devgen);
if(c->qid.path == Qmouse){
/*
* mouse:
* 'm' 1
* buttons 1
* point 8
* msec 4
*/
if(n < 14)
error(Ebadblt);
while(mousechanged(0) == 0)
sleep(&mouse.r, mousechanged, 0);
lock(&cursor);
p = va; ************************
accessing va could cause a page fault which could
sleep in a qlock in seg() or reading the page.
A simple solution is to add
uchar buf[14];
and then replace
lock(&cursor);
p = buf;
p[0] = 'm';
......
unlock(&cursor);
memmove(va,buf,14);
There are plenty of places in plan9 where we could
sleep holding a spin-lock. For example in the same driver
Chan*
bitopen(Chan *c, int omode)
{
GBitmap *b;
if(!conf.monitor)
error(Egreg);
switch(c->qid.path){
case CHDIR:
...
case Qmouse:
...
case Qbitblt:
lock(&bit);
if(bit.bitbltopen || bit.mouseopen){
unlock(&bit);
error(Einuse);
}
b = smalloc(sizeof(GBitmap));***************
smalloc could sleep while holding bit.
We actually added some code to qlock and sleep so
we capture calls while holding spin-locks.
reply other threads:[~1997-05-10 1:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19970510013028.-QZTMy2Rm4tPJWAl6vS8khzatHb-G68d1bO4TiIid-w@z \
--to=beto@ncube.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).