Consider two classes: foo and bar

Assignment Help C/C++ Programming
Reference no: EM13938507

Consider two classes: Foo and Bar, where Foo is a sender, and Bar the receiver.
Foo allocates 3-1 megabyte chunks of memory. The first chunk is filled with the value 0xA5, the next chunk with value 0xB5 and the third - 0xC5.

In a header file, that Foo will transmit to Bar. The struct _order_ will advise Bar of the order in which to exepct the 3 1 MiB chunks.
So now:
chunk_id size
0 1 megabyte
1 1 megabyte
2 1 megabyte

struct order { unsigned int chunk_id; unsigned int size; };
struct process{ unsigned int chunk_id; unsigned int step; };

struct header_info
{
order co[3];
process po[3];
};
header_info hdr;
hdr.co[0].chunk_id = 0;
hdr.co[0].size = 0x100000;
hdr.co[1].chunk_id = 1;
hdr.co[1].size = 0x100000;
hdr.co[2].chunk_id = 2;
hdr.co[3].size = 0x100000;

Similarily, Foo will fill out the processing order via the process struct. The process struct will advise Bar of when to 'start processing'.
So now - assume the order is as follows:

chunk_id steps
1 2
0 1
2 1

hdr.po[0].chunk_id = 1;
hdr.po[0].step = 2;
hdr.po[1].chunk_id = 0;
hdr.po[1].step = 1;
hdr.po[2].chunk_id = 2;
hdr.po[3].step = 1;

So the header - header_info (first) gets transmitted from Foo to Bar.
Upon receipt of this header Bar is aware of the order the information will arrive based on the struct _order_. Bar also knows the order to start processing based on the struct process.

So now - Foo transmits the data to Bar. i.e 1 megabyte of 0xA5. Upon receipt of the data, Bar will 'store the data', then check the initial chunk_id of order (0) versus the chunk_id of process (1). In this case, both id's aren't equivalent so Bar is available for more data. To do this. Bar informs Foo of it's availability to receive more data.

Foo then transmits the next chunk corresponding to chunk_id 1. Data values 0xB5. Upon receipt of the data, Bar - yet again, 'stores the data', then checks the chunk_id of order (1) versus the chunk_id of process (1). It's a match. Bar will now start processing. Processing here is simple. Bar will multiply the data - in this case - 0xB5 by 2. Bar will do this twice since the parameter 'step is set to 2'. Bar will 'move to the next processing chunk_id'. Per the example the id is 0. Since Bar has already received chunk_id 0 (Bar will need to do housekeeping to keep track of chunk_id's received based on the order struct), Bar will process the data. Processing here is multiplying 0xA5 by 3. We'll do this once, since step is 1.

At this point Bar informs Foo of it's availabilty to receive more data.

At this point Foo transmits data value 0xC5 to Bar. Bar will once again validate (always validate to ensure we didn't receive a bogus chunk_id) the chunk_id of 'order' with the chunk_id of 'process'. In this case both id's are 2 (recall that we're -i.e Bar - told in advance the order the data will arrive - via the order struct. That said it's up to Bar to do all the housekeeping when to start processing and if it's ok to continue processing based on previously received data). Bar once again does processing. i.e multiplies 0xC5 by 4 and doing so once (step 1)

My question: I'm interested in an implementation (working source) that'll capture the information above.

Strict C++ is required. i.e operator new (no malloc) and where necessary C++ STL containers is preferred over C style arrays.

Reference no: EM13938507

Questions Cloud

Write a main function that declares an array of 10 grocery : Write a main() function that declares an array of 10 GroceryItem objects. Assign values to all 10 items and display them.
According to the capital asset pricing model : According to the Capital Asset Pricing Model, the introduction of a risk-free asset renders the efficient frontier of efficient portfolios linear. How many portfolios of risky assets (portfolios of only risky assets) lie on the resulting Capital Mark..
Exposure stage-interaction stage-e-commerce stage : Determine whether it is in the exposure stage, interaction stage, e-commerce stage or e-business stage. Provide reasons for your answer.
What is market price of stock if market rate of return : The Extreme Reaches Corp. last paid a $1.50 per share annual dividend. The company is planning on paying $3.00, $5.00, $7.50, and $10.00 a share over the next four years, respectively. After that the dividend will be a constant $2.50 per share per ye..
Consider two classes: foo and bar : Consider two classes: Foo and Bar, where Foo is a sender, and Bar the receiver.Foo allocates 3-1 megabyte chunks of memory. The first chunk is filled with the value 0xA5, the next chunk with value 0xB5 and the third - 0xC5.
Returns on crash-n-burn computer’s stock over past five year : You’ve observed the following returns on Crash-n-Burn Computer’s stock over the past five years: 5 percent, -11 percent, 24 percent, 18 percent, and 17 percent. What was the arithmetic average return on Crash-n-Burn’s stock over this five year period..
What physically connects, or bridges, the two parts : The entire process of coordinated, voluntary, muscle contraction is summed up as excitation-contraction coupling. Why are these two things coupled, and what, specifically, is responsible for bring excitation and contraction together in the muscle ..
Why would that cause a physiological change : Why would administering bicarbonate to a patient be advisable if his blood pH was too low? What is the bicarbonate going to do to adjust the pH of the blood?
You report statistical data in this article : The article should follow similar headings to your abstract (the first four only) though you may have additional subheadings specific to your topic. It is not expected that you report statistical data in this article. You can however provide a cri..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Pointer variables to demonstrate shallow and deep copy

Using C++, write a program that uses pointer variables to demonstrate shallow and deep copy. The program should give the user the choice to do the following:

  Write equivalent compound statements

What action must be taken before a variable can be used in a program?

  Evaluate the circumference of a circle

Write a program that will call a function to calculate the area of a circle, and call another function to calculate the circumference of a circle.

  Random permutations

Write a program in C++ that gives a prompt to the users, asking for an integer M.It then prints out a M different random permutations, one on each of M lines, of the numbers 1, 2, ... , 10, separated by spaces or tabs.

  Write c program to find the distance travel

Write C program to find the distance travelled at regular intervals of time given the values of 'u' and 'a'. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different values of '..

  Translate than c source code

Why does Ada take so much more time to translate than C source code? What phase of the Ada translation takes the longest?

  What is an abstract data type

1. What is an Abstract Data Type (ADT) for? Illustrate answer with any particular ADT. 2. write out in pseudocode an algorithm to perform a depth-first search for a directed, unweighted graph.

  Part asuggest an application system which is able to

part asuggest an application system which is able to perform some arithmetic computations like commission system

  Write a short c++ function

Write a short C++ function, isMultiple, that takes two positive long values, n and m, and returns true if and only if n is a multiple of m, that is, n = mi for some integer i.

  Write a function named digit_name

Write a function named "digit_name" that takes an integer argument in the range from 1 to 9 , inclusive, and prints the English name for that integer on the computer screen.

  Write a switch statement that assigns a string variable

Write a switch statement that assigns a String variable monthName with the months January, February, March, April, May, and June, ifmonthNum is 1, 2, 3, 4, 5, 6, accordingly.

  Which of the following is a true statement

Which of the following is a true statement?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd