Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91609384
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As