[ECOS] Any problem ?

Andrew Lunn andrew@lunn.ch
Fri Mar 25 15:55:00 GMT 2011


On Fri, Mar 25, 2011 at 09:24:15AM -0600, Gary Thomas wrote:
> On 03/25/2011 09:17 AM, ratheesh kannoth wrote:
> >Is there any prob with below code segment  in eCos ?
> >
> >{
> >                fd_set rd_fds;
> >
> >                FD_ZERO(&rd_fds);
> >
> >                 while (1) {
> >
> >                           timeout.tv_sec = 1;
> >                           timeout.tv_usec = 0;
> >
> >                          if (select(0,&rd_fds, NULL, NULL,&timeout)<  0) {
> >                                       printf("\n  Error \n");
> >                                       sleep(1);
> >                                       continue;
> >                           }
> >
> >                          printf("\n  Success  \n");
> >                  }
> >   }
> >
> 
> Yes - the first parameter to select() is the number of open file
> descriptors to check (fd in 0..N-1).  Putting a zero there will
> never yield any activity.

Hi Gary

I this case it does not matter. rd_fds is all zero, since there is no
call to FD_SET() for any file descriptor. So i would expect this code
fragment to do:

	 <sleep 1>
         "\n  Success  \n"
	 <sleep 1>
         "\n  Success  \n"
	 <sleep 1>
         "\n  Success  \n"
	 <sleep 1>
         "\n  Success  \n"
	 <sleep 1>
         "\n  Success  \n"

	 Andrew	 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list