Skip to main content.
Navigation:
DENX
>
Training2
>
LddPollAndSelect
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
Training2
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
Training2 Home
Changes
Index
Search
Go
List of pages in Training2
Search
%SECTION0{name=LddPollAndSelect}% =poll= and =select= *View from Userspace:* * process can check if one or more files can be read from or written to without blocking * this allows to work with multiple file descriptors * example: telnet: reads from socket and terminal, can't block on either! * But why? We've got: * =O_NONBLOCK=, we can poll? -> yes, but this wastes CPU time! * threads -> yes, but threads are considered problematic for [[Training2.UnixIPCToAvoid][many reasons]] *View from Kernelspace:* * driver: 1 call =poll_wait= on one or more waitqueues that inform of change of =poll=/=select= status (typically read and write queue) 1 return a bitmask describing what operations can be performed without blocking. * kernel: if a requested operation is possible the kernel returns, otherwise sets process to sleep on waitqueues and handles timeouts. ---++API: poll *header and poll operation* <verbatim> #include <linux/poll.h> unsigned int poll(struct file *filp, poll_table *wait); </verbatim> *step 1: add waitqueues* <verbatim> void poll_wait(struct file*, wait_queue_head_t *, poll_table *); </verbatim> *step 2: return appropriate status (more in [[http://lxr.linux.no/linux/include/asm-generic/poll.h][asm/poll.h]])* <verbatim> /* readable */ return (POLLIN | POLLRDNORM); /* writeable */ return (POLLOUT | POLLWRNORM); </verbatim>
5.3.6. Non-Blocking IO
1. Denx Training Topics
5.3.8. Memory mapping
Prev
Home
Next