LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2008, 10:11 AM   #1
gsp
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
Strange behavior with posix async I/O


Hi - Any help with this one sure would be appreciated.

OS: Centos 5 Kernel 2.6.22
Compiler: Gnu C++

I'm using the posix async I/O routines (io_prep_pread, io_prep_pwrite, io_submit) to read and write some data files asynchronously, harvesting the completion status using io_getevents and I'm experiencing some behavior that I can't explain. If this is normal behavior, the "documentation" certainly hides it well.

The first maddening thing is that when I run my application in gdb, io_getevents continually returns a status of -4. (I think this is -EAGAIN) I'm calling it with my I/O context variable, a minimum event count of 1, a maximum of 10 and the timer parameter is NULL. So what's up with this? Why am I getting a -4 while in gdb? It makes it slightly more challenging to debug any problems. I DO eventually get a '1' when an outstanding I/O completes, so I've coded around this anomaly.

Next, (and more importantly) I'm getting odd behavior if I inadvertently try to read past the end of file. No, I shouldn't be trying to read past the end of file, but darn it, if I do try, the OS should TELL me that I had an end of file error. The problem is, when this event completes, the res and res2 fields of the io_event struct are zero. Zero tells me nothing, other than "there were zero bytes transferred". Well, yeah. But WHY? I should have some I/O status SOMEwhere that indicates the reason for the error, but I get nothing. Can anyone shed some light on this?

Thanks in advance.
Greg
 
Old 04-16-2008, 09:31 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
From POSIX
Quote:
The errors reported by aio_error() and aio_return() include all of the
errors normally reported by read() and write() plus errors unique to
asynchronous I/O processing. After an asynchronous I/O operation is
started but before an error is detected or the operation completes
successfully, aio_error() will return EINPROGRESS.
Are you calling aio_return and aio_error?
 
Old 04-17-2008, 09:06 AM   #3
gsp
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Jim: Thanks for the reply.

No, I'm not calling those routines. There seems to be two "flavors" of asynch I/O. I'm using the interface defined in libaio.h by Benjamin LaHaise (not aio.h) Has libaio.h been deprecated in favor of this aio.h interface?

The only I/O completion context that I have is an iocb (not an aiocb). Similar in structure, but definitively different.

Greg
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strange blocking behavior gearoid_murphy Programming 5 11-17-2007 02:05 PM
XMMS strange behavior jskalsi Linux - Software 1 05-03-2006 06:23 PM
Very Strange Behavior raysr Mandriva 4 08-31-2004 02:06 PM
Strange Behavior andrewb758 Linux - Hardware 5 08-31-2003 02:42 PM
strange behavior abhijit Linux - General 3 07-09-2003 11:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration