design guidance

Discussion in 'C++' started by ma740988, Jan 17, 2006.

  1. ma740988

    ma740988 Guest

    I inquired about utilizing a vector of pairs just yesterday and after
    receiving some feedback, I got to thinking my thoughts with regards to
    my initial 'approach' was flawed to begin with:

    Here's my 'dilema' in a nutshell. I've got 24 sources ( call them 0
    ... 23 )
    sending data to a recipient ( call this 'X' ). The data from each
    source has
    what's called an 'id' (call it segment id) assosciated with it.

    Today, I've got a maximum of two id's ( 0 and 1 ).
    X will receive from all sources, a source id, a segment id and data
    size. So now:

    struct from_source_to_x { // transmitted from all sources (
    0...24) to X
    unsigned int the_segment;
    unsigned int the_source_id;
    unsigned int the_size_of_data;

    Upon receipt of the data from _all_ sources, X will perform processing
    on the data. X knows (via a structure that's sent to it intially )
    that the processing order is segment 0 followed by segment 1. i.e
    process segment 0 first followed by segment 1.

    So on X, the very first thing X receives before anything is a table
    that tells X the processing order:
    segment what_to_do
    0 IFFT // I want to an IFFT
    1 FFT // do an FFT here

    The trouble on X is all the 'required house keeping that goes along
    with receipt of the segments' from the 24 sources.

    Having said that - on X (i.e local to X) - I need to track three
    1. The size of the segment per source
    2. The address where I store the segment - for _each_ source on X
    3. A count parameter to keep track of things.

    In it's simplest form. Lets assume source 0 transmits segment 0, with
    a size of 0x10000;

    // so now source 0 fills out the from_source_to_x composite
    from_source_to_x source0;
    source0.the_segment = 0; // I source 0 just did something
    with data on segment 0
    source0.the_source_id = 0; // Here's my source_id
    source0.the_size_of_data = 0x100000; // Here's the results size of
    what I came up with

    Upon receipt of the the above header. The code executing on "X' will.
    Increment the count parameter associated with _that_ source (i.e
    source 0), store the size of data from source 0, and the keep track of
    the offset in memory where I stored source 0's data.

    Now do that X will do that the remainder. i.e receive data from a
    source, increment the count, store the addresss of where the data was
    moved and the size of the data.

    If the count == 24, then X has received results from every source - for
    segment 0.
    if ( count0 = 1 && count1 = 1 && .. up to count23 == 1 )
    // I've received all the data.
    // do an IFFT on all the data.

    X then will do an IFFT on the data from all the sources. Once 'X' is
    complete with its' processing on segment 0. X will 'request' segment
    1 from the sources. I'm executing in a
    multi-threaded environment but enviornment 'details' aside, that's it
    in a nutshell.

    Now here's where it gets tricky for me - the design aspect of this.

    Pictorially my thoughts were a map where first would be the
    'what_to_do', second is a struct that entails - segment id, sources,
    source counts, source data size, offset in memory. So now:

    __ what_to_do_ segment_id
    IFFT 0
    0........ 24 (24) sources
    0 ....... 0 (24) counts - all
    zeros initially
    X1.......X24 (24) data size - this
    we'll get from every source
    Y1......Y24 (24) address in memory
    - this part is tricky but doable.

    Trouble is, something just doesn't seem right about the use of map

    That said, I'm interested in design guidance. After think about this.
    I'm thinking a chain of responsibilty pattern might be prudent here.
    Bottom line: I'll take a suggestion (source snippet) and will go off
    an implement it.

    I tend to struggle with getting the 'design going'. The real
    tricky/confusing aspect of this is trying to detemine if
    1. I've received all the results.
    2. How do I now, 'walk' through a struct or (?) and get the address of
    every source and the size of the data. Whew!!

    Thanks in advance.
    ma740988, Jan 17, 2006
    1. Advertisements

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. Brendan Duffy
    Brendan Duffy
    Jul 25, 2003
  2. Robert Hanson
    Robert V. Hanson
    Jul 3, 2003
  3. Replies:
  4. Guest
    Steven Cheng[MSFT]
    Dec 29, 2006
  5. Rusty Hill

    Design Guidance Wanted

    Rusty Hill, May 30, 2007, in forum: ASP .Net
  6. Rusty Hill

    Design Guidance Wanted

    Rusty Hill, May 30, 2007, in forum: ASP .Net Building Controls
  7. Rusty Hill

    Design Guidance Wanted

    Rusty Hill, May 30, 2007, in forum: ASP .Net Web Controls
  8. Ken Fine
    Ken Fine
    Aug 14, 2003