473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

struggling with a design approach ......

Consider a board with two processors A and B. A receive 16 MiB of data
in 2 MiB chunks.
Upon receipt of data A will 'keep' the first 8 MiB. The remainder A
will B will transfer to B.

My current approach works but I question the maintainability.
Because of 'board specific API calls' I'll provide a pseduo code
version of my current approach on the the board with the two
processors.

So now:
size_t const kilobyte(1024);
size_t const mebibyte(kilobyte*kilobyte);
bool new_msg_available(true); // assume true first time
unsigned int count(0);
size_t const payload(2 * mebibyte);
size_t source[payload];
size_t dest[8 * mebibyte];
size_t dest2[8 * mebibyte];

void test_func::rx_data_from_sender()
{
while (1)
{
// semTake (some_sema, -1);<- wait forever on a semaphore [1]

if ( new_msg_available )
{
size_t const msg_size(16 * mebibyte); // [2]
size_t const num_runs = msg_size / mebibyte;
//size_t const distribution = msg_size / payload;
new_msg_available = false;
count = 0;
}

if (count < (num_runs / 2))
{
memcpy(source, dest, payload); [3]
++count;
}

if (count >= num_runs ) // now 'copy' to B's memory
{
memcpy(source, dest2, payload);
++count;
}
if (count == num_runs) new_msg_available = true; // reset
}
}
Item [1] is RTOS 'functionality'
[2] The size varies and is obtained from a header. For demonstration
purposes I hard coded it.
[3] is not a memcpy but we use memcpy for demonstration purposes.

This of course is a synopsis. I suspect - perhaps - a chain of
responsibility approach would suffice here because in reality I ahve 4
processors on card. The example only show 2.

I'd like to be able to derive from a class and have objects maintain
their own state. When object A is done it hands off to B. B when
complete will 'reset'. I'm having a hard time determining how to do
this. Sample source appreaciated.

Thanks

Sep 29 '05 #1
1 1098
On 29 Sep 2005 15:23:08 -0700, ma******@gmail.com wrote:
Consider a board with two processors A and B. A receive 16 MiB of data
in 2 MiB chunks.
Upon receipt of data A will 'keep' the first 8 MiB. The remainder A
will B will transfer to B.


It sounds like you could use a state machine. Hint:

enum state_t { RECEIVING_FIRST_HALF, RECEIVING_SECOND_HALF };

state_t state = RECEIVING_FIRST_HALF;

/* ... */

while (true) {
switch (state) {
case RECEIVING_FIRST_HALF:
/* ... */
if (received_bytes >= SOME_THRESHOLD) {
state = RECEIVING_SECOND_HALF;
}
break;

case RECEIVING_SECOND_HALF:
/* ... */
if (received_bytes >= SOME_OTHER_THRESHOLD) {
state = RECEIVING_FIRST_HALF;
}
break;
}
}
Oct 1 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Omer van Kloeten | last post by:
The Top Level Design: The class Base is a factory class with a twist. It uses the Assembly/Type classes to extract all types that inherit from it and add them to the list of types that inherit...
26
by: dagger | last post by:
Hi there. I'm using C under FreeBSD with the gcc compiler and am having a bit of trouble using the calloc and realloc calls. As an example the code snippet: #include <stdio.h> int main() {...
5
by: | last post by:
I am really struggling to conceptually understand classes in C# especially the use of the strange keywords 'static' 'void' and 'override'.... Is there a 'idiots' way of understanding these...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
160
by: RG | last post by:
Greetings friends, This semester I have started a course in C programming. I was moving along fine until I reached to the topic of loops (feeling embarrassed among you elite programmers). My...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
3
by: Mousam | last post by:
Hi All, First of all forgive me for the length of this post. I am developing one library for some text editor. In this library I want to provide a set of C++ classes which will enable client (of...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
0
by: jsimone | last post by:
This question is about DB2 table design and performance. We are using DB2 UDB Enterprise 8.2 on Linux. We have 6 tables in a parent-child (one-to-many) relationship with each other. Each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.