Would not the select() stop the application, forcing it to wait for the data?
The application (real time simulation) cannot block or run timeouts or spend any time testing to see if data is available. The only time it wants to be bothered is when data is available, otherwise "leave-me-alone". Since the I/O is async it seems that a push system is more advantagous... Granted signals are more complicated, but they might be necessary in some cases. I fiddled with a very non-elegant approach where the driver set a flag in the data file and the application read the file (about 64 chars) on each pass and tested the flag, if true it accepted the data and reset the flag with a write to the file, if false it ignored the data. It works but waste CPU resources big time... You spend all the effort to design a Ferrari (the interrupt driver and board) and then install a VW engine(the fiddle thingy) to make it run ;-) Thanks for the put John W. ----- Original Message ----- From: "Jeff Newmiller" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, September 15, 2003 10:26 AM Subject: Re: [vox-tech] Driver Question > On Sun, 14 Sep 2003, Mark K. Kim wrote: > > > I think I understood it correctly but I wasn't sure exactly how to do it > > so I was just giving you some pointers. Anyway, I'm sorta interested in > > this too so I poked around a bit some more. Looks like the easiest > > technique is to: > > > > (1) Trap SIGIO signal using signal() system call. > > (2) fcntl(fd, F_SETFL, O_ASYNC); > > (3) fcntl(fd, F_SETOWN, getpid()); (might not be necessary) > > (4) wait for SIGIO signal, handle it in your signal handler. > > > > I haven't tried it. If it doesn't work, refer to the "fcntl" man page and > > look for any information on asynchronous I/O (grep for "async"). If that > > doesn't work either, try reading section 12.6 in "Advanced Programming in > > the UNIX Environment" by W. Richard Stevens. > > I still think select() is the way to go. (Mark beat me to the punch.) > Signals are an unnecessarily complicated way to approach the problem. > > The select() call will block until your driver has data available. You > can timeout periodically if you want to provide UI updates like clock > displays, but select() lets you block on one or more streams until they > have input, which seems perfect for the application. > > -------------------------------------------------------------------------- - > Jeff Newmiller The ..... ..... Go Live... > DCN:<[EMAIL PROTECTED]> Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/Batteries O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...2k > -------------------------------------------------------------------------- - > > > _______________________________________________ > vox-tech mailing list > [EMAIL PROTECTED] > http://lists.lugod.org/mailman/listinfo/vox-tech _______________________________________________ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
