Asynchronous i/o?

Discussion in 'C Programming' started by deostroll, Dec 30, 2008.

  1. deostroll

    deostroll Guest

    Hi,

    I was just wondering if the modern pure c/c++ compilers have any
    support for asynchronous file handling? If so in what header files are
    they located in...? Any samples would be beneficial. Thanx in advance.

    --deostroll
     
    deostroll, Dec 30, 2008
    #1
    1. Advertising

  2. deostroll

    jacob navia Guest

    deostroll wrote:
    > Hi,
    >
    > I was just wondering if the modern pure c/c++ compilers have any
    > support for asynchronous file handling? If so in what header files are
    > they located in...? Any samples would be beneficial. Thanx in advance.
    >
    > --deostroll


    Asynchronous file i/o is supported by the OS not by the compiler. ALL
    the compiler can possible do is to generate calls to APIs provided by
    the operating system.

    For instance under windows, the lcc-win compiler supports access to all
    asynchronous i/o APIs provided by the windows OS.

    To use them you should just

    #include <windows.h>

    You can find all the documentation about those APIs with the SDK
    provided for free by Microsoft Corp.


    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Dec 30, 2008
    #2
    1. Advertising

  3. deostroll wrote:
    > I was just wondering if the modern pure c/c++ compilers have any
    > support for asynchronous file handling? If so in what header files are
    > they located in...? Any samples would be beneficial. Thanx in advance.


    The C Standard does not define any asynchronous I/O functions. However,
    your implementation may provide some, such as the "aio" family under
    POSIX, and any reasonable compiler will let you access them. You will
    have to ask in a group specific to your implementation for details,
    though, since it's off-topic in clc.

    S
     
    Stephen Sprunk, Dec 30, 2008
    #3
  4. deostroll

    user923005 Guest

    user923005, Dec 30, 2008
    #4
  5. deostroll

    CBFalconer Guest

    jacob navia wrote:
    > deostroll wrote:
    >
    >> I was just wondering if the modern pure c/c++ compilers have any
    >> support for asynchronous file handling? If so in what header
    >> files are they located in...? Any samples would be beneficial.
    >> Thanx in advance.

    >
    > Asynchronous file i/o is supported by the OS not by the compiler.
    > ALL the compiler can possible do is to generate calls to APIs
    > provided by the operating system.


    So far, OK.

    >
    > For instance under windows, the lcc-win compiler supports access
    > to all asynchronous i/o APIs provided by the windows OS.
    > To use them you should just
    >
    > #include <windows.h>
    >
    > You can find all the documentation about those APIs with the SDK
    > provided for free by Microsoft Corp.


    But here you are advising using components not available in C.
    Standard C has no <windows.h> header file, and using it will make
    the program non-portable to any non-windows system, and probably to
    any non lcc-win32 compiler.

    Believe it or not, there are machines and systems other than
    Windows in existence. They are off-topic on c.l.c. Use a Windows
    newsgroup to discuss them.

    --
    Merry Christmas, Happy Hanukah, Happy New Year
    Joyeux Noel, Bonne Annee, Frohe Weihnachten
    Chuck F (cbfalconer at maineline dot net)
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Dec 30, 2008
    #5
  6. deostroll

    Guest

    On Dec 30, 7:23 am, jacob navia <> wrote:
    > deostroll wrote:
    > > Hi,

    >
    > > I was just wondering if the modern pure c/c++ compilers have any
    > > support for asynchronous file handling? If so in what header files are
    > > they located in...? Any samples would be beneficial. Thanx in advance.

    >
    > > --deostroll

    >
    > Asynchronous file i/o is supported by the OS not by the compiler. ALL
    > the compiler can possible do is to generate calls to APIs provided by
    > the operating system.



    I think the OP wanted to know if the standard C (or C++) library
    provided access to such a thing. Not even the new C++ standard adds
    AIO support, although it does add threading.
     
    , Dec 31, 2008
    #6
  7. deostroll

    deostroll Guest

    On Dec 30, 8:40 pm, Stephen Sprunk <> wrote:
    > deostroll wrote:
    > > I was just wondering if the modern pure c/c++ compilers have any
    > > support for asynchronous file handling? If so in what header files are
    > > they located in...? Any samples would be beneficial. Thanx in advance.

    >
    > The C Standard does not define any asynchronous I/O functions.  However,
    > your implementation may provide some, such as the "aio" family under
    > POSIX, and any reasonable compiler will let you access them.  You will
    > have to ask in a group specific to your implementation for details,
    > though, since it's off-topic in clc.
    >
    > S


    Does the standard have anything that lets us do "asynchronous
    operations" generally speaking?

    --deostroll
     
    deostroll, Dec 31, 2008
    #7
  8. deostroll

    Flash Gordon Guest

    deostroll wrote:

    <snip>

    > Does the standard have anything that lets us do "asynchronous
    > operations" generally speaking?


    Generally speaking, no. The closest it comes is signal handling and,
    IMHO, that is not very close at all and more limited than most people think.
    --
    Flash Gordon
     
    Flash Gordon, Dec 31, 2008
    #8
  9. deostroll

    James Kuyper Guest

    deostroll wrote:
    > On Dec 30, 8:40 pm, Stephen Sprunk <> wrote:
    >> deostroll wrote:
    >>> I was just wondering if the modern pure c/c++ compilers have any
    >>> support for asynchronous file handling? If so in what header files are
    >>> they located in...? Any samples would be beneficial. Thanx in advance.

    >> The C Standard does not define any asynchronous I/O functions. However,
    >> your implementation may provide some, such as the "aio" family under
    >> POSIX, and any reasonable compiler will let you access them. You will
    >> have to ask in a group specific to your implementation for details,
    >> though, since it's off-topic in clc.
    >>
    >> S

    >
    > Does the standard have anything that lets us do "asynchronous
    > operations" generally speaking?


    Yes - it's called "undefined behavior". That's what allows the use of
    non-portable implementation-specific code (such as calls to the POSIX
    aio family of functions) which implements asynchronous operations.
    You'll have to go to implementation-specific documentation, not the C
    standard, in order to find out how to do this.
     
    James Kuyper, Dec 31, 2008
    #9
  10. On 31 Dec 2008 at 6:48, deostroll wrote:
    > Does the standard have anything that lets us do "asynchronous
    > operations" generally speaking?


    Yes, the latest POSIX standard describes the aio_read(), aio_write() and
    related functions.

    A more traditional way of achieving this is using threads - I assume
    you've already considered this and decided that the overhead would be
    too great for your application. There's also good old select() or
    poll(), though of course that's not /really/ asynchronous I/O.
     
    Antoninus Twink, Dec 31, 2008
    #10
  11. deostroll

    jameskuyper Guest

    Malcolm McLean wrote:
    > "James Kuyper" <> wrote in message
    > >
    > > Yes - it's called "undefined behavior". That's what allows the use of
    > > non-portable implementation-specific code (such as calls to the POSIX aio
    > > family of functions) which implements asynchronous operations. You'll have
    > > to go to implementation-specific documentation, not the C standard, in
    > > order to find out how to do this.
    > >

    > A C program with undefined behaviour is incorrect. It may behave correctly,
    > for instance terminating the program with an error message, or might even do
    > what the programmer wants, but it is not a correct program.


    It is not an incorrect program if either the implementation or some
    standard other than the C standard (for instance, the POSIX standard)
    provides a definition of the behavior that is not defined by the C
    standard. It's just not as portable as it would be if it were capable
    of relying only upon the C standard's guarantees.
     
    jameskuyper, Dec 31, 2008
    #11
  12. Malcolm McLean wrote:
    > "James Kuyper" <> wrote in message
    >>
    >> Yes - it's called "undefined behavior". That's what allows the use of
    >> non-portable implementation-specific code (such as calls to the POSIX
    >> aio family of functions) which implements asynchronous operations.
    >> You'll have to go to implementation-specific documentation, not the C
    >> standard, in order to find out how to do this.
    >>

    > A C program with undefined behaviour is incorrect. It may behave
    > correctly, for instance terminating the program with an error message,
    > or might even do what the programmer wants, but it is not a correct
    > program.
    > Implementation-defined behaviour, however, is not incorrect. The
    > programmer may rely upon it if he knows the platform the program will be
    > compiled for.
    > Asynchronous operations are likely to be implementation-defined.


    In terms of the C standard, many things are undefined. Other standards
    (e.g. POSIX) may define those things, but as far as C is concerned,
    they're still undefined -- not implementation-defined.

    S
     
    Stephen Sprunk, Dec 31, 2008
    #12
  13. deostroll

    CBFalconer Guest

    deostroll wrote:
    > 8:40 pm, Stephen Sprunk <> wrote:
    >> deostroll wrote:
    >>
    >>> I was just wondering if the modern pure c/c++ compilers have
    >>> any support for asynchronous file handling? If so in what
    >>> header files are they located in...? Any samples would be
    >>> beneficial. Thanx in advance.

    >>
    >> The C Standard does not define any asynchronous I/O functions.
    >> However, your implementation may provide some, such as the "aio"
    >> family under POSIX, and any reasonable compiler will let you
    >> access them. You will have to ask in a group specific to your
    >> implementation for details, though, since it's off-topic in clc.

    >
    > Does the standard have anything that lets us do "asynchronous
    > operations" generally speaking?


    Sure. The application just needs to be able to respond to an 'Are
    you busy' call, or to send an interrupt when it goes non-busy
    (operation complete). Nothing special is needed.

    --
    Merry Christmas, Happy Hanukah, Happy New Year
    Joyeux Noel, Bonne Annee, Frohe Weihnachten
    Chuck F (cbfalconer at maineline dot net)
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Jan 1, 2009
    #13
  14. deostroll

    deostroll Guest

    On Jan 2, 4:21 am, CBFalconer <> wrote:
    > deostroll wrote:
    > > 8:40 pm, Stephen Sprunk <> wrote:
    > >> deostroll wrote:

    >
    > >>> I was just wondering if the modern pure c/c++ compilers have
    > >>> any support for asynchronous file handling? If so in what
    > >>> header files are they located in...? Any samples would be
    > >>> beneficial. Thanx in advance.

    >
    > >> The C Standard does not define any asynchronous I/O functions.
    > >> However, your implementation may provide some, such as the "aio"
    > >> family under POSIX, and any reasonable compiler will let you
    > >> access them.  You will have to ask in a group specific to your
    > >> implementation for details, though, since it's off-topic in clc.

    >
    > > Does the standard have anything that lets us do "asynchronous
    > > operations" generally speaking?

    >
    > Sure.  The application just needs to be able to respond to an 'Are
    > you busy' call, or to send an interrupt when it goes non-busy
    > (operation complete).  Nothing special is needed.
    >
    > --
    > Merry Christmas, Happy Hanukah, Happy New Year
    >  Joyeux Noel, Bonne Annee, Frohe Weihnachten
    > Chuck F (cbfalconer at maineline dot net)
    >      <http://cbfalconer.home.att.net>- Hide quoted text -
    >
    > - Show quoted text -


    I believe the standard has provision to allow us create threads right?

    --deostroll
     
    deostroll, Jan 4, 2009
    #14
  15. deostroll <> writes:
    [...]
    > I believe the standard has provision to allow us create threads right?


    Not specifically, no. An implementation may provide threads as an
    extension.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Jan 4, 2009
    #15
  16. deostroll

    CBFalconer Guest

    deostroll wrote:
    > CBFalconer <> wrote:
    >> deostroll wrote:
    >>

    .... snip ...
    >>
    >>> Does the standard have anything that lets us do "asynchronous
    >>> operations" generally speaking?

    >>
    >> Sure. The application just needs to be able to respond to an
    >> 'Are you busy' call, or to send an interrupt when it goes
    >> non-busy (operation complete). Nothing special is needed.

    >
    > I believe the standard has provision to allow us create threads
    > right?


    Wrong. Which is why threads are off-topic here. There are groups
    that deal with that.

    Please snip signatures and any material not germane to your message
    in your replies.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.
     
    CBFalconer, Jan 4, 2009
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amir

    asynchronous design

    Amir, Oct 10, 2003, in forum: VHDL
    Replies:
    3
    Views:
    607
  2. Jamie
    Replies:
    13
    Views:
    7,629
    Renaud Pacalet
    Oct 23, 2003
  3. Jamie
    Replies:
    4
    Views:
    1,039
    Thomas Stanka
    Oct 22, 2003
  4. Georges Konstantinidis

    asynchronous counter an Xilinx FPGA for a newbie

    Georges Konstantinidis, Jan 30, 2004, in forum: VHDL
    Replies:
    12
    Views:
    5,960
  5. HUANG Huan
    Replies:
    2
    Views:
    682
    Dave Higton
    Feb 24, 2004
Loading...

Share This Page