Find the answer to your Linux question:
Results 1 to 3 of 3
hello everybody, Trying to learn a about aio in the linux kernel. I would like to know about how is it different from normal read and is there a way ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    16

    Asynchronous Input/Output

    hello everybody,

    Trying to learn a about aio in the linux kernel. I would like to know about how is it different from normal read and is there a way out by which that can be shown via a program. I have written the following program, which on compilation shows the following errors:
    undefined reference to "aio_error"
    undefined reference to "aio_return"


    #include<aio.h>
    #include<stdio.h>
    #include<sys/types.h>
    #include<fcntl.h>
    #include<sys/stat.h>
    #include<strings.h>
    #include<stdlib.h>

    #define SIZE 100


    int main()
    {
    struct aiocb demo;
    int fd,ret,i=0;
    fd=open("4.dat",O_RDONLY);
    if(fd<0)
    {perror("open");
    return 1;
    }


    //initializing with zero bytes
    bzero((void*)&demo,sizeof(struct aiocb));

    demo.aio_buf=malloc(SIZE);
    if(!demo.aio_buf)
    perror("malloc");
    demo.aio_fildes=fd;
    demo.aio_nbytes = SIZE;
    demo.aio_offset=0;




    if(ret<0)
    perror("aio_read");
    while(aio_error(&demo))
    i++;
    printf("&#37;d",i);
    if((ret=aio_return(&demo))>0)
    printf("%d",ret);

    return 0;
    }

    /***************xxxxx************/


    Please help me out??

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    "Undefined reference" means the linker is complaining that he can't find the actual object code of some functions that your code depends on. Without this, he can't lump the final executable together, because a part is missing.

    You can solve that by finding out which library contains these objects and tell gcc to link that library. This is done with the -l switch.

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    16
    thanks, the program is working. can you elaborate on aio and on how the request is scheduled differently than a normal synchronous blocking i/o request?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...