Re: Synchronizing driver with user mode application

2006-10-29 Thread Oron Peled
On Sunday, 29 בOctober 2006 09:34, Michael Sternberg wrote:
 I want to ask how reliable to use signals to notify user mode application 
 from driver ?

An indirect answer... I think you look at the problem from the wrong
side. It is much more complicated (though possible) to synchronize
user space from the kernel. It is far better to do it from user space
to the kernel.

Example:
  Application  Kernel
  ---  --

  n = read(fd,...) wait_event_interruptible(...)
   /* wake_up is called somewhere */
  /* read returns data */

If you need read() for something else, than you can achieve
the same with ioctl (which you already use) or any other
I/O oriented blocking system call.

If your application has other things to do in the meantime, than
you can use all the async I/O paradigms in Linux. Some common examples:
 * select() / poll() (maybe wrapped in libevent)
 * Separate processes (or God forbid threads ;-)
 * aio_* API (in modern 2.6 kernels)

All these alternative follow common and simple Unix/Linux methodology
and don't force weird and complicated API's between application and kernel.

-- 
Oron Peled Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]  http://www.actcom.co.il/~oron
ICQ UIN: 16527398

First they ignore you, 
then they laugh at you, 
then they fight you, 
then you win. -- Gandhi

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Synchronizing driver with user mode application

2006-10-29 Thread Baruch Even
* Michael Sternberg [EMAIL PROTECTED] [061029 09:43]:
 Hello everybody.
 
 I want to ask how reliable to use signals to notify user mode
 application from driver ? I have a driver that stops every I/O and
 sends a signal to user mode application. After that user mode
 application send ioctl to release that I/O. Driver is not supposed to
 send another signal until it did not received ioctl from user mode.
 I've added some traces and have seen that sometimes signal is sent by
 driver but never reaches the application. Of course that could be my
 bug but still - how reliable the signals are ? What another mechanisms
 are exist to synchronize driver with user mode application ?

A better method would be to have an open file descriptor from the
application to the driver, possibly in the form of a character driver so
the driver can write to device and the application will read it. It will
give you a signalling system and the driver will be notified once the
user program died for some reason since the device will be closed.

Cheers,
Baruch

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Synchronizing driver with user mode application

2006-10-29 Thread Shachar Shemesh
Oron Peled wrote:
  * aio_* API (in modern 2.6 kernels)
   
A complete sidetracking here. Are you sure it's 2.6 kernels only?

The man page lists aio_read under section 3 (library functions), while
Advanced Programming in the UNIX Environment - Second Edition states
that Linux version 2.4.22 already has it. Likewise, the man page doesn't
mention anything about it.

Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting ltd.
Have you backed up today's work? http://www.lingnu.com/backup.html


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Synchronizing driver with user mode application

2006-10-29 Thread Muli Ben-Yehuda
On Sun, Oct 29, 2006 at 11:17:47AM +0200, Shachar Shemesh wrote:
 Oron Peled wrote:
   * aio_* API (in modern 2.6 kernels)

 A complete sidetracking here. Are you sure it's 2.6 kernels only?
 
 The man page lists aio_read under section 3 (library functions), while
 Advanced Programming in the UNIX Environment - Second Edition states
 that Linux version 2.4.22 already has it. Likewise, the man page doesn't
 mention anything about it.

IIRC, 2.4 has aio implemented in glibc whereas 2.6 has it implemented
in the kernel. Same interface, completely different performance
characteristics.

Cheers,
Muli

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]