how to use select( )???

Hi everyone,

I have read in the qnx tutorial about select function, but i have some doubts about the sample program that is given in the tutorial. The tutorial says that :

/This example opens a console and a serial port for
read mode, and calls select() with a 5 second timeout.
It waits for data to be available on either descriptor
/


FD_ZERO( &rfd );
FD_SET( console, &rfd );
FD_SET( serial, &rfd );


select(…);

my question is where does the waitting occurs? and why?
Please refer to this link:
qnx.com/developer/docs/qnx_6 … elect.html

Thanks in advance…

b_tamayo

select will block, wait for event on files descriptor specifed by rfd. While “waiting” it will not consume CPU time. As the why, well that’s the nature of select to wait for something to happen instead of constantly checking (polling) for it, which is a bad thing in general.

Does that anwer your question?