Asynchronous I/O?

Aaron J. Grier aaron at frye.com
Tue May 13 17:06:09 UTC 2003


On Thu, May 08, 2003 at 05:10:31PM -0700, Kamen Penev wrote:
> Is there a standard way of doing asynchronous I/O in RTEMS? It looks
> like the POSIX aio_* functions are just stubs.
> 
> Basically, I want a non-blocking write to the console that fails
> instead of blocking the caller.

I've implemented this in one of my device drivers, controllable via
fcntl.  on userland you do something like:

	flags = fcntl(fd, F_GETFL, NULL);
	flags |= FNBIO;
	fcntl(fd, F_SETFL, flags);

and on the driver side:

	rtems_device_driver device_write(
	    rtems_device_major_number	major,
	    rtems_device_minor_number	minor,
	    void			*arg
	) {
		[...]
		rtems_libio_rw_args_t	*rw_args;
		unsigned32		nonblocking;
		[...]

		rw_args = (rtems_libio_rw_args_t *) arg;
		nonblocking = rw_args->flags & LIBIO_FLAGS_NO_DELAY;

		if (nonblocking) {
			/* non blocking routine here, set errno on error
			 * and return RTEMS_UNSATISFIED or the like */
		} else {
			/* block */
		}
		[...]
	}

for serial routines, you can either roll-your-own or stitch into the
existing termios routine from within your driver.

-- 
  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron at frye.com



More information about the users mailing list