From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 26 21:28:37 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 CD17F16A4CE for ; Sun, 26 Dec 2004 21:28:37 +0000 (GMT) Received: from hanoi.cronyx.ru (hanoi.cronyx.ru [144.206.181.53]) by mx1.FreeBSD.org (Postfix) with ESMTP id E006643D31 for ; Sun, 26 Dec 2004 21:28:36 +0000 (GMT) (envelope-from rik@cronyx.ru) Received: (from root@localhost) by hanoi.cronyx.ru (8.13.0/vak/3.0) id iBQLPZTM029147 for freebsd-hackers@freebsd.org.checked; Mon, 27 Dec 2004 00:25:35 +0300 (MSK) (envelope-from rik@cronyx.ru) Received: from cronyx.ru (hanoi.cronyx.ru [144.206.181.53]) by hanoi.cronyx.ru (8.13.0/vak/3.0) with ESMTP id iBQLMsr8029130; Mon, 27 Dec 2004 00:22:54 +0300 (MSK) (envelope-from rik@cronyx.ru) Message-ID: <41CF297E.60505@cronyx.ru> Date: Mon, 27 Dec 2004 00:13:34 +0300 From: Roman Kurakin User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.2.1) Gecko/20030426 X-Accept-Language: ru-ru, en MIME-Version: 1.0 To: Norbert Koch References: <000a01c4e9bf$fc7e56a0$fe78a8c0@k62300> In-Reply-To: <000a01c4e9bf$fc7e56a0$fe78a8c0@k62300> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: 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: Sun, 26 Dec 2004 21:28:37 -0000 Hi, 1) man tsleep 2) tsleep is just msleep with NULL mutex. if you check sys/kern/kern_synch.c you will see KASSERT (ident != NULL && ... ident is exactly the first parameter. rik Norbert Koch: >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. >_______________________________________________ >freebsd-hackers@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > >