From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 24 13:49:42 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A24BB16A4CE for ; Fri, 24 Dec 2004 13:49:42 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 425ED43D45 for ; Fri, 24 Dec 2004 13:49:41 +0000 (GMT) (envelope-from nkoch@gmx.com) Received: (qmail invoked by alias); 24 Dec 2004 13:49:39 -0000 Received: from C3B3BE2B.dial.de.easynet.net (EHLO k62300) (195.179.190.43) by mail.gmx.net (mp005) with SMTP; 24 Dec 2004 14:49:39 +0100 X-Authenticated: #472702 From: "Norbert Koch" To: Date: Fri, 24 Dec 2004 14:53:45 +0100 Message-ID: <000a01c4e9bf$fc7e56a0$fe78a8c0@k62300> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Y-GMX-Trusted: 0 X-Mailman-Approved-At: Fri, 24 Dec 2004 16:21:05 +0000 Subject: parameters for tsleep(9) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Dec 2004 13:49:42 -0000 Hello. I am just writing a device driver for the i82527 (can-bus) chip. For testing I need the driver to poll the chip instead of running in interrupt mode. My dev_t read function basically looks like this: for (;;) { while (chip_has_data(...)) { read_chip_data(...); error = do_uiomove(...); if (error || enough_read(...)) { return error; } }; if (do_not_block_on_read(...)) { return EWOULDBLOCK; } error = tsleep (XXX, PCATCH|PWAIT, "canrd", hz / 10); if (error != EWOULDBLOCK) { return error; } } XXX should be 'something' which could be used as parameter to wakeup(9), I read in tsleep(9). In the kernel source tree I found one place where tsleep _only_ sleeps: in sys/isa/ppc.c (which already seems to be in the attic [?] but still is in my computer's source tree). Here, the first parameter was set to NULL. Doing this I found, that tsleep immediately returns 0 (which means: wakueup was called) _without_ waiting. I even crashed or froze the kernel by calling tsleep (NULL, ...) for a random number of times. After changing this to the address of the read-function itself, all worked fine. No more crashes. Just for my understanding: Is this a bug? Does the first parameter have to point to something useful? Is it allowed to point it to a code position? Or should I use some kind of dummy data in the softc structure instead? What about the second parameter: Is PWAIT ok here or should I use PZERO or whatever? (And btw, why has ppc.c been removed?) Thank you.