View topic - how to use select( )???

how to use select( )???

anything that doesn't fit to other groups.

how to use select( )???

Postby b_tamayo » Thu Jan 29, 2004 6:06 pm

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 );



my question is where does the waitting occurs? and why?
Please refer to this link: ... elect.html

Thanks in advance...

New Member
Posts: 5
Joined: Fri Jan 16, 2004 4:12 am

Postby mario » Fri Jan 30, 2004 1:48 am

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?
QNX Master
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Return to General Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests