Date: Sat, 01 Jun 2002 10:32:28 -0400 (EDT) From: John Baldwin <jhb@FreeBSD.org> To: kai ouyang <oykai@msn.com> Cc: current@FreeBSD.org Subject: RE: Help! Message-ID: <XFMail.20020601103228.jhb@FreeBSD.org> In-Reply-To: <OE1349FFf70DQLGJZGT0000e264@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 01-Jun-2002 kai ouyang wrote:
> Hi, everybody
> I am working on transfer RaidFrame from FreeBSD4.x to FreeBSD5.0. Scott Long has transfered
> RAIDFrame from NetBSD to FreeBSD 4.x.
> Now, I am transfering those codes to FreeBSD5.0. This is my first strolling in FreeBSD5.0 kernel.
> Firstly, I transfered some codes based on the relationship of vinum and ccd between 4.x and 5.0.
> It could compile successfully.
> Now when I boot the box, the system tell me:
> panic: sleeping without a mutex
> Debugger("panic")
> Stopped at Debugger+0x40: xorl %eax,%eax
>
> I traced the source code and found some information as follow:
> These is a function on RAIDFrame in the FreeBSD4.x .
> static __inline int
> RF_LTSLEEP(void *cond, int pri, const char *text, int time, struct simplelock *mutex)
> {
> int ret;
> if (mutex != NULL)
> simple_unlock(mutex);
> ret = tsleep(cond, pri, text, time);
> if (mutex != NULL)
> simple_lock(mutex);
> return (ret);
> }
>
> These is the above funtion I modifed to support FreeBSD5.0:
> static __inline int
> RF_LTSLEEP(void *cond, int pri, const char *text, int time, struct mtx *mutex)
> {
> int ret;
> if (mutex != NULL)
> mtx_unlock(mutex);
> ret = tsleep(cond, pri, text, time);
> if (mutex != NULL)
> mtx_lock(mutex);
> return (ret);
> }
>
> I have a clear ideal to use mtx.
> I think there are maybe some problem in using the mtx.
> Thank you very much!
Use msleep instead of tsleep so it properly interlocks to avoid lost wakeups, thus:
static __inline int
RF_LTSLEEP(void *cond, int pri, const char *text, into time, struct mtx *mutex)
{
return (msleep(cond, mutex, pri, text, time);
}
or better yet:
#define RF_LTSLEEP(cond, pri, text, time, mtx) msleep((cond), (mtx), (pri), (text), (time))
--
John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020601103228.jhb>
