double buffering technique

Discussion in 'C Programming' started by MPowell, Aug 18, 2003.

  1. MPowell

    MPowell Guest

    Gents/Ladies, I'm doing (at least plan on ) lots of Reads and Writes
    across a communication channel. I'm told that for the 'receive side'
    it'd be prudent to implement a double buffering scheme to handle all
    the asnychronous inputs.

    Someone mentioned Herb Shutters book as frame of reference,
    nonetheless, could someone provide sample code or - in effect an
    outline of double buffering? I've perused the web but most references
    are to 'GUI' applications which - quite frankly I'm not interested in.

    If I understand double buffering, the idea is to create two buffers.
    Lets say Buffer A and Buffer B. Now lets suppose data comes in to
    Buffer A. The idea then is to swap Buffer A with Buffer B and as such
    the next asnychronous input will write to Buffer B.

    Thanks in advance.
    MPowell, Aug 18, 2003
    #1
    1. Advertising

  2. MPowell wrote:

    > Gents/Ladies, I'm doing (at least plan on ) lots of Reads and Writes
    > across a communication channel. I'm told that for the 'receive side'
    > it'd be prudent to implement a double buffering scheme to handle all
    > the asnychronous inputs.
    >
    > Someone mentioned Herb Shutters book as frame of reference,
    > nonetheless, could someone provide sample code or - in effect an
    > outline of double buffering? I've perused the web but most references
    > are to 'GUI' applications which - quite frankly I'm not interested in.
    >
    > If I understand double buffering, the idea is to create two buffers.
    > Lets say Buffer A and Buffer B. Now lets suppose data comes in to
    > Buffer A. The idea then is to swap Buffer A with Buffer B and as such
    > the next asnychronous input will write to Buffer B.
    >
    > Thanks in advance.


    You're very close.
    The idea about using multiple buffers is that data is inserted into
    one buffer while data is extracted from another. If the insertion
    operation is faster than the extraction operation, multiple buffers
    may be necessary.

    Multiple buffers are used when the insertion and extraction operations
    are performed asychronously, usually by two different processors.
    For example, a communications processor (USB, USART, etc.) could be
    told to dump to Buffer A. After Buffer A is full, it is told to
    dump to buffer B. While it is dumping to buffer B, the processor
    is extracting data from Buffer A and processing it.

    See also:
    1. Ring Buffers
    2. Circular Queues
    3. Deques

    Further discussion is best handled in news:comp.programming
    since this is a language independent issue.

    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.raos.demon.uk/acllc-c /faq.html
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    Thomas Matthews, Aug 18, 2003
    #2
    1. Advertising

  3. MPowell

    Eric Sosman Guest

    MPowell wrote:
    >
    > Gents/Ladies, I'm doing (at least plan on ) lots of Reads and Writes
    > across a communication channel. I'm told that for the 'receive side'
    > it'd be prudent to implement a double buffering scheme to handle all
    > the asnychronous inputs.
    >
    > Someone mentioned Herb Shutters book as frame of reference,
    > nonetheless, could someone provide sample code or - in effect an
    > outline of double buffering? I've perused the web but most references
    > are to 'GUI' applications which - quite frankly I'm not interested in.
    >
    > If I understand double buffering, the idea is to create two buffers.
    > Lets say Buffer A and Buffer B. Now lets suppose data comes in to
    > Buffer A. The idea then is to swap Buffer A with Buffer B and as such
    > the next asnychronous input will write to Buffer B.


    Your understanding seems correct, but Standard C can't
    do what you want. Specifically, Standard C has no notion --
    or very nearly no notion -- of asynchronous activities of
    any kind at all, and lacks the mechanisms to coordinate them.
    You'll need to resort to system-specific extensions that go
    beyond the scope of the C language itself, and to learn about
    those extensions you should consult newsgroups devoted to the
    systems of interest.

    --
    Eric Sosman, Aug 18, 2003
    #3
    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. Sandeep

    Double Buffering in ASP.NET

    Sandeep, Aug 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    819
    bruce barker
    Aug 10, 2004
  2. Rob Love
    Replies:
    1
    Views:
    3,291
    dhek bhun kho
    Jul 2, 2003
  3. Replies:
    1
    Views:
    913
    Knute Johnson
    Aug 29, 2003
  4. David

    Help on double buffering

    David, Nov 23, 2003, in forum: Java
    Replies:
    0
    Views:
    326
    David
    Nov 23, 2003
  5. Sydex
    Replies:
    12
    Views:
    6,475
    Victor Bazarov
    Feb 17, 2005
Loading...

Share This Page