[uClinux-dev] Re: [uClinux-dev] Two questions about drivers

gerg gerg at snapgear.com
Thu Nov 29 08:38:07 EST 2001

Hi Joey,

JoeyShen wrote:
> It's very nice of you, Greg!
> I can always count on your answers :).


> >Follow the flow of execution from the open system call
> >entry point in ~/linux/fs/open.c, function is sys_open().
> OK, I will read it. There are still too many things to do before I can go further with linux.:)

Overall is is pretty strait forward.

> >Yes. It is up to the driver code to honor the O_NONBLOCK flag.
> >(And you don't need this flag to use select(). The idea is that
> >you select until you can read, and thus the read will not block
> >when you do call it).
> Um...that's it! I think I understand now. I can open the devices without the O_NONBLOCK flag , then I select them, and when the interrupt occurs (that means something have arrived at the buffer), FD_ISSET will tell me which device can be read. So when I'm gonna read it, it will not block. Am I right?

Yes, that is right.

> but there is still one more question. How dose select( ) know about when interrupts occur, and then set the flags so that FD_ISSET can tell? Should I do something in the interrupt handlers?

The exact method depends on the kernel version. Older 2.0.x
kernels use a "select" routine in the driver (part of the
"file_operations" structure). Newer 2.4.x use a driver "poll"
function to acheive the same result.

Basically the select/poll sleeps on a wait queue that your
interrupt routine wakes up on. (The select/poll driver
functions have special sleep calls they use select_wait/

You don't need to worry about the FD_ISSET bits in the driver,
the kernel fs support will take care of that part for you (based
on the return status of your drivers select/poll function).


Greg Ungerer  --  Chief Software Wizard        EMAIL:  gerg at snapgear.com
Snapgear                                       PHONE:    +61 7 3279 1822
825 Stanley St,                                  FAX:    +61 7 3279 1820
Woolloogabba, QLD, 4102, Australia               WEB:   www.snapgear.com
This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/

More information about the uClinux-dev mailing list