Re: locking in a device driver

2005-11-03 Thread Julian Elischer
M. Warner Losh wrote: In message: <[EMAIL PROTECTED]> Sergey Babkin <[EMAIL PROTECTED]> writes: : Maybe it can be fixed in the kernel without : too much trouble. It already is in libthr and libposix. They already use execution contexts to map M threads onto N contexts. libc_r is be

Re: locking in a device driver

2005-11-03 Thread Julian Elischer
Sergey Babkin wrote: From: "M. Warner Losh" <[EMAIL PROTECTED]> Scott Long <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : > : > : > On 11/03/05 03:12 Warner Losh said the following: : > : >> Yes. if you tsleep with signals enabled, the periodic timer will go : >> off, and you'

Re: locking in a device driver

2005-11-03 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Sergey Babkin <[EMAIL PROTECTED]> writes: : Maybe it can be fixed in the kernel without : too much trouble. It already is in libthr and libposix. They already use execution contexts to map M threads onto N contexts. libc_r is being retired and not wort

Re: Re: locking in a device driver

2005-11-03 Thread Sergey Babkin
>From: "M. Warner Losh" <[EMAIL PROTECTED]> >Scott Long <[EMAIL PROTECTED]> writes: >: Dinesh Nair wrote: >: > >: > >: > On 11/03/05 03:12 Warner Losh said the following: >: > >: >> Yes. if you tsleep with signals enabled, the periodic timer will go >: >> off, and you'll return earl

Re: locking in a device driver

2005-11-03 Thread Andrey Simonenko
On Thu, Nov 03, 2005 at 04:55:10AM +0800, Dinesh Nair wrote: > > On 11/03/05 04:27 M. Warner Losh said the following: > >that this is the case: sleep in an ioctl, and the entire process hangs > >until the ioctl returns. > > which is probably what's happening in my case. i've got 4 threads spun of

Re: locking in a device driver

2005-11-02 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Scott Long <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : > : > : > On 11/03/05 03:12 Warner Losh said the following: : > : >> Yes. if you tsleep with signals enabled, the periodic timer will go : >> off, and you'll return early. This typically i

Re: locking in a device driver

2005-11-02 Thread Dinesh Nair
On 11/03/05 05:15 Scott Long said the following: before the ioctl call runs. But it does work. Look at the aac(4) driver for my example of this. i will, it sounds like a good solution. The other option is to use rfork, aka 'linuxthreads' to similate threads i could try with linuxthreads

Re: locking in a device driver

2005-11-02 Thread Dinesh Nair
On 11/03/05 05:17 M. Warner Losh said the following: this is to create a helper program that gets the ioctl request over a pipe or socket, does the call to the kernel and then returns the results. Not idea, I'll grant, but it is an alternative worth no, that wont work. the userland app is ast

Re: locking in a device driver

2005-11-02 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Dinesh Nair <[EMAIL PROTECTED]> writes: : : : On 11/03/05 03:12 Warner Losh said the following: : > Yes. if you tsleep with signals enabled, the periodic timer will go : > off, and you'll return early. This typically isn't what you want : > either. :

Re: locking in a device driver

2005-11-02 Thread Scott Long
Dinesh Nair wrote: On 11/03/05 03:12 Warner Losh said the following: Yes. if you tsleep with signals enabled, the periodic timer will go off, and you'll return early. This typically isn't what you want either. looks like i've got a lot of work to do, poring thru all the ioctls for the d

Re: locking in a device driver

2005-11-02 Thread Dinesh Nair
On 11/03/05 04:27 M. Warner Losh said the following: that this is the case: sleep in an ioctl, and the entire process hangs until the ioctl returns. which is probably what's happening in my case. i've got 4 threads spun off, and one thread reads what the other writes and vice versa. after wri

Re: locking in a device driver

2005-11-02 Thread Dinesh Nair
On 11/03/05 03:12 Warner Losh said the following: Yes. if you tsleep with signals enabled, the periodic timer will go off, and you'll return early. This typically isn't what you want either. looks like i've got a lot of work to do, poring thru all the ioctls for the device and trying to us

Re: locking in a device driver

2005-11-02 Thread Julian Elischer
M. Warner Losh wrote: In message: <[EMAIL PROTECTED]> Julian Elischer <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : : > : > : > On 10/28/05 10:52 M. Warner Losh said the following: : > : >> libc_r will block all other threads in the application while an ioctl : >> executes. li

Re: locking in a device driver

2005-11-02 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Julian Elischer <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : : > : > : > On 10/28/05 10:52 M. Warner Losh said the following: : > : >> libc_r will block all other threads in the application while an ioctl : >> executes. libpthread and libthr won't

Re: locking in a device driver

2005-11-02 Thread Julian Elischer
Dinesh Nair wrote: On 10/28/05 10:52 M. Warner Losh said the following: libc_r will block all other threads in the application while an ioctl executes. libpthread and libthr won't. I've had several bugs at work so if the userland thread does an ioctl, and the the driver goes to tsleep(

Re: locking in a device driver

2005-11-02 Thread Warner Losh
From: Dinesh Nair <[EMAIL PROTECTED]> Subject: Re: locking in a device driver Date: Thu, 03 Nov 2005 02:23:32 +0800 > > > On 10/28/05 10:52 M. Warner Losh said the following: > > libc_r will block all other threads in the application while an ioctl > > executes.

Re: locking in a device driver

2005-11-02 Thread Julian Elischer
Dinesh Nair wrote: On 11/02/05 06:12 Julian Elischer said the following: depends on what they are using it for.. if it's a WAN interface, then splimp. (INTR_TYPE_NET) if ppp or several other moduels are loaded, teh tty and net masks are combined anyhow.. it's a quad-span E1/T1 line card

Re: locking in a device driver

2005-11-02 Thread Dinesh Nair
On 10/28/05 10:52 M. Warner Losh said the following: libc_r will block all other threads in the application while an ioctl executes. libpthread and libthr won't. I've had several bugs at work so if the userland thread does an ioctl, and the the driver goes to tsleep() when the ioctl is rec

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 11/02/05 06:16 Julian Elischer said the following: also, why do you need a pseudo device AND a device? The device driver can do all the things you have suggested on its own. this is so userland apps wont need to change when different devices are used. the pseudo device is the front for a

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 11/02/05 06:12 Julian Elischer said the following: depends on what they are using it for.. if it's a WAN interface, then splimp. (INTR_TYPE_NET) if ppp or several other moduels are loaded, teh tty and net masks are combined anyhow.. it's a quad-span E1/T1 line card which would be carryin

Re: locking in a device driver

2005-11-01 Thread Julian Elischer
Dinesh Nair wrote: On 11/02/05 03:51 Scott Long said the following: INTR_TYPE_TTY and spltty [..snipped..] You'll also want to use an spl in the top half of the pseudo driver to cover where the pointers are read and changed. thanx a bunch. i'll rewrite the portions affected based on yo

Re: locking in a device driver

2005-11-01 Thread Julian Elischer
Scott Long wrote: Dinesh Nair wrote: On 11/02/05 03:02 Julian Elischer said the following: drops to splzero or similar,.. woken process called, starts manipulating "another buffer" collides with next interrupt. that makes a lot of sense, i'll try with using splxxx() in the pseudo driv

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 11/02/05 03:51 Scott Long said the following: INTR_TYPE_TTY and spltty [..snipped..] You'll also want to use an spl in the top half of the pseudo driver to cover where the pointers are read and changed. thanx a bunch. i'll rewrite the portions affected based on yours and julian's suggest

Re: locking in a device driver

2005-11-01 Thread Scott Long
Dinesh Nair wrote: On 11/02/05 03:02 Julian Elischer said the following: drops to splzero or similar,.. woken process called, starts manipulating "another buffer" collides with next interrupt. that makes a lot of sense, i'll try with using splxxx() in the pseudo driver, to block out the r

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 11/02/05 03:02 Julian Elischer said the following: drops to splzero or similar,.. woken process called, starts manipulating "another buffer" collides with next interrupt. that makes a lot of sense, i'll try with using splxxx() in the pseudo driver, to block out the real driver. it's curre

Re: locking in a device driver

2005-11-01 Thread Julian Elischer
Julian Elischer wrote: Dinesh Nair wrote: On 11/02/05 00:03 Scott Long said the following: I think this thread has gone too far into hyperbole and conjecture. What is your code trying to do, and what problems are you seeing? apologies, scott. i'm actually trying to get a driver written

Re: locking in a device driver

2005-11-01 Thread Julian Elischer
Dinesh Nair wrote: On 11/02/05 00:03 Scott Long said the following: I think this thread has gone too far into hyperbole and conjecture. What is your code trying to do, and what problems are you seeing? apologies, scott. i'm actually trying to get a driver written for freebsd 5.x backporte

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 11/02/05 00:03 Scott Long said the following: I think this thread has gone too far into hyperbole and conjecture. What is your code trying to do, and what problems are you seeing? apologies, scott. i'm actually trying to get a driver written for freebsd 5.x backported to 4.x. the driver wo

Re: locking in a device driver

2005-11-01 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Dinesh Nair <[EMAIL PROTECTED]> writes: : : : On 10/28/05 16:40 Dinesh Nair said the following: : > : > : > On 10/28/05 10:52 M. Warner Losh said the following: : > : >> libc_r will block all other threads in the application while an ioctl : >> execu

Re: locking in a device driver

2005-11-01 Thread Scott Long
Dinesh Nair wrote: On 10/28/05 16:40 Dinesh Nair said the following: On 10/28/05 10:52 M. Warner Losh said the following: libc_r will block all other threads in the application while an ioctl executes. libpthread and libthr won't. I've had several bugs at work which is a Good Thing(

Re: locking in a device driver

2005-11-01 Thread Dinesh Nair
On 10/28/05 16:40 Dinesh Nair said the following: On 10/28/05 10:52 M. Warner Losh said the following: libc_r will block all other threads in the application while an ioctl executes. libpthread and libthr won't. I've had several bugs at work which is a Good Thing(tm) indeed for me on 4

Re: locking in a device driver

2005-10-28 Thread Dinesh Nair
On 10/27/05 22:00 Scott Long said the following: If you need to protect your pseudodriver from being interrupted by the real driver then you'll need to use the same spl() as the driver. Note that you shouldn't be using splhigh() unless you really know what you the driver currently is set to u

Re: locking in a device driver

2005-10-28 Thread Dinesh Nair
On 10/28/05 10:52 M. Warner Losh said the following: libc_r will block all other threads in the application while an ioctl executes. libpthread and libthr won't. I've had several bugs at work which is a Good Thing(tm) indeed for me on 4.x. -- Regards, /\_/\ "All

Re: locking in a device driver

2005-10-27 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Dinesh Nair <[EMAIL PROTECTED]> writes: : the userland application uses pthreads, and works like a charm both on 4.x : and 5.x without using the device. however, when the device is used, it : somehow has synchronization errors on 4.x, leading to timers

Re: locking in a device driver

2005-10-27 Thread Dinesh Nair
On 10/27/05 22:00 Scott Long said the following: are doing. Other than that, there likely isn't anything that you need to do for 'locking' in 4.x. The kernel is non-reentrant there, so you don't need to worry about synchronizing multiple threads. thanx a bunch, scott. it's been a nightmare t

Re: locking in a device driver

2005-10-27 Thread Scott Long
M. Warner Losh wrote: In message: <[EMAIL PROTECTED]> Scott Long <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : > : > carrying on this discussion, what would be a good locking mechanism to : > use to protect tsleep() and other sensitive areas in a driver in freebsd : > 4.x ? :

Re: locking in a device driver

2005-10-27 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]> Scott Long <[EMAIL PROTECTED]> writes: : Dinesh Nair wrote: : > : > carrying on this discussion, what would be a good locking mechanism to : > use to protect tsleep() and other sensitive areas in a driver in freebsd : > 4.x ? : > : > the current code

Re: locking in a device driver

2005-10-27 Thread Scott Long
Dinesh Nair wrote: carrying on this discussion, what would be a good locking mechanism to use to protect tsleep() and other sensitive areas in a driver in freebsd 4.x ? the current code for the driver in 5.x uses mtx_lock and mtx_unlock with some parts even being protected by mtx_lock(&Gian