Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > aio_read Help

Reply
Thread Tools

aio_read Help

 
 
danu
Guest
Posts: n/a
 
      08-01-2006
I'm trying to read asynchronously from a file using aio_read:

/* async I/O structures */
struct aiocb cb;
const struct aiocb* list[1] = { &cb };
int aioRet;

/* set appropriate values in control buffer */
cb.aio_fildes = fromfd;
cb.aio_buf = buffer0;
cb.aio_nbytes = BUFSIZE;
cb.aio_sigevent.sigev_notify = SIGEV_NONE;

while(1) {

/* copy one block asynchronously */
aioRet = aio_read(&cb);

if (aioRet == -1) {
fprintf(stderr, "%s", " aio_read failed:: ");
perror("");
exit(EXIT_FAILURE);
};
count++;
if(count == 5) break;

}

But when I tried to do this I'm getting an error message saying:
aio_read failed:: Invalid argument

I can't move on further in my program because of this read failure.
what's the reason for this?
I highly suspect it's because I'm trying to do aio_read in a while
loop. (when I remove the while loop it seem works) How do I fix this.
Do I have to use aio_suspend ? I tried that but it didn't resolve the
issue. may be I'm using it in a wrong way.

any help would be highly appreciated. Thanks in advance guys.

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      08-01-2006
"danu" <> writes:
> I'm trying to read asynchronously from a file using aio_read:

[snip]

aio_read is not standard C. Try asking in a newsgroup that's specific
to your system.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      08-01-2006
danu wrote:
> I'm trying to read asynchronously from a file using aio_read:


Good luck, aio_read is not part of the C standard so we don't know
anything about it.

>
> /* async I/O structures */
> struct aiocb cb;


Perhaps you should do:
struct aiocb cb = { 0 };
to ensure all fields are initialised.

<snip>

> /* copy one block asynchronously */
> aioRet = aio_read(&cb);
>


<snip>

> But when I tried to do this I'm getting an error message saying:
> aio_read failed:: Invalid argument


<snip>

> any help would be highly appreciated. Thanks in advance guys.


Try asking in a group dedicated to your system. There you might find
someone who knows about aio_read.
--
Flash Gordon
Still sigless on this computer.
 
Reply With Quote
 
William Ahern
Guest
Posts: n/a
 
      08-01-2006
On Mon, 31 Jul 2006 23:17:13 -0700, danu wrote:

> I'm trying to read asynchronously from a file using aio_read:
>
> /* async I/O structures */
> struct aiocb cb;
> const struct aiocb* list[1] = { &cb }; int aioRet;
>
> /* set appropriate values in control buffer */
> cb.aio_fildes = fromfd;
> cb.aio_buf = buffer0;
> cb.aio_nbytes = BUFSIZE;
> cb.aio_sigevent.sigev_notify = SIGEV_NONE;
>
> while(1) {
>
> /* copy one block asynchronously */
> aioRet = aio_read(&cb);
>
> if (aioRet == -1) {
> fprintf(stderr, "%s", " aio_read failed:: "); perror("");
> exit(EXIT_FAILURE);
> };
> count++;
> if(count == 5) break;
>
>
> }
> But when I tried to do this I'm getting an error message saying: aio_read
> failed:: Invalid argument
>
> I can't move on further in my program because of this read failure. what's
> the reason for this?
> I highly suspect it's because I'm trying to do aio_read in a while loop.
> (when I remove the while loop it seem works) How do I fix this. Do I have
> to use aio_suspend ? I tried that but it didn't resolve the issue. may be
> I'm using it in a wrong way.


It would indeed look like you're using aio_read improperly. Nothing you're
doing is asynchronous.

> any help would be highly appreciated. Thanks in advance guys.


Try comp.unix.programmer. The POSIX AIO interface is newish, so you might
have to exercise some patience.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
A question about the gettimeofday(2) and aio_read(3) yueyu Java 0 01-23-2007 09:13 AM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57