From owner-freebsd-current Sat Jun 1 7:33:24 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail.speakeasy.net (mail16.speakeasy.net [216.254.0.216]) by hub.freebsd.org (Postfix) with ESMTP id 274E537B40F for ; Sat, 1 Jun 2002 07:32:43 -0700 (PDT) Received: (qmail 26302 invoked from network); 1 Jun 2002 14:32:42 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail16.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 1 Jun 2002 14:32:42 -0000 Received: from laptop.baldwin.cx (laptop.baldwin.cx [192.168.0.4]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g51EX2F43118; Sat, 1 Jun 2002 10:33:02 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Sat, 01 Jun 2002 10:32:28 -0400 (EDT) From: John Baldwin To: kai ouyang Subject: RE: Help! Cc: current@FreeBSD.org Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 <>< 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