thread management conundrum

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
Gravis
Experienced Member
Posts: 75
Joined: Thu Feb 02, 2012 3:32 pm

thread management conundrum

Post by Gravis »

i'm working on this project and have run into a bit of a snag.

here's an outline of the situation.

threads:
2x - capture camera data
1x - worker thread manager
16x - worker thread

channels:
capture camera datas <--> worker thread manager
worker thread manager <--> worker threads

description:
after capturing a few kilobytes of data in a capture camera data thread it should send an alert to the worker thread manager that it has data that should go to a worker thread to be processed.

question:
how cant i send data from a capture camera data thread to send data directly to a worker thread? i need maximum speed on this so relaying data is not ok. i'm fine with using inline assembly.


yzoer
XCore Addict
Posts: 133
Joined: Tue Dec 15, 2009 10:23 pm

Post by yzoer »

Can you post as snippet of your flow / functions? I did a similar thing a while ago where I had one manager thread that was receiving blocks from multiple threads. In your case, I'm guessing you have a similar setup like this:

2x camera theads -> 2 channels feeding to work manager thread

work manager thread has 2 input channels from camera threads and 1 channel to each worker thread.

The work manager thread is probably the most 'complicated' as it needs to respond to the 2 camera threads AND the 16 worker threads. That means it'll have a 'select' portion that basically loops and peeks at the channels, so you'll loose a (little) bit of performance there.

If the worker thread is busy, the camera thread MIGHT block for a few cycles, so you may want to be wary of that..

The worker thread should basically be a single channel to the manager thread and take data, process it and pass it back or alternatively, have 2 channels: one for input and one for output.

Just speculating here until we see your code :-)

-Y

P.S. To your question, you'll need a manager thread or your camera threads might stall..
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm
Contact:

Post by Folknology »

It depends on where the threads reside relative to each other, clearly from your numbers some of the threads will be on different cores (more threads than a single core can handle) and therefore different memory spaces (remember threads on same core share memory space, threads on different cores do not). Thus you will need to use channels to move the data. In order to reduce transfer overhead use either channel based transactions or streaming channels between those threads.


regards
Al
Post Reply