Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Urgent: Asychronous I/O in Unix

Posted on 1998-11-11
3
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
braveheart earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

722 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