Solved

Urgent: Asychronous I/O in Unix

Posted on 1998-11-11
3
264 Views
Last Modified: 2010-04-21
Please tell me how to simulate asynchronous I/O in Unix.i.e
If I am using  normal
fread( void *buffer, size_t size, size_t count, FILE *stream);
 command in my program the calling Unix process will block until the transfer is complete.

In Win32 we have the option like this

BOOL ReadFile( HANDLE hFile,  // handle of file to read
               LPVOID lpBuffer,  // address of buffer                                 that receives data
               DWORD nNumberOfBytesToRead,  // number of                                 bytes to read
               LPDWORD lpNumberOfBytesRead,
                        // address of number of bytes read
              LPOVERLAPPED lpOverlapped
                       // address of structure for data );
If lpoverlapped is not NULL then
Here the lpOverlapped will be filled up by windows with some internal status info & my process will not block.Instead it will execute instructions written next to point where i made call to this command.
After some time if I want to test the status of my I/O I can use
BOOL GetOverlappedResult( HANDLE hFile,
       // handle of file, pipe, or communications device
                         LPOVERLAPPED lpOverlapped,
      // address of overlapped structure
                         LPDWORD lpNumberOfBytesTransferred,
      // address of actual bytes count
                         BOOL bWait
      // wait flag );
which will return the status of I/O.So I have no need to wait for I/O to complete.
Please give me ways to simulate similar Asynchronous activity in Unix.I do not think it should be impossible  to simulate above two API's using unix API.
Please send me any source code examples if you can.
Please provide some discrete solution.

Thanking in advance..
0
Comment
Question by:flower020397
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
braveheart earned 500 total points
ID: 2007763
See the man pages for "aio_read" and related routines.
Use "man -k asynchronous" to discover a full list of related pages

aio_read combines all the arguments into a single structure but has similar information to the ReadFile routine.

aio_result can be used in a similar way to GetOverlappedResult.

Note that these routines are specific to AIX so if you port to a different flavour of UNIX you will need to take this into account. For instance, on Solaris the equivalent routines have no underscore and may have slightly different functionality.
0
 

Author Comment

by:flower020397
ID: 2007764
Thanks for the help.
If you have written some sample source code  please send me.
It can be helpful for me.
0
 
LVL 3

Expert Comment

by:braveheart
ID: 2007765
Sorry. All I did was check the man pages.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
error while running the scirpt 24 125
removing nim resources 5 48
File sharing syncing(Production to DR, DR back to Production) 2 28
Write an app 10 66
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now