when is it safe to use a channel

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
boeserbaer
Active Member
Posts: 51
Joined: Fri Jan 29, 2010 4:36 pm

when is it safe to use a channel

Post by boeserbaer »

In my application, I have a communications thread, which also handles the GP input, and must communicate the GP input ports values to another thread. this seems to work OK if I I don't let it immediately communicate with the other thread, but when I attempt to communicate with another thread too soon, it seems to hang on the:

channel <: data; // hangs here

When is it safe to use a channel? How can I recover from error?

regards, Mike


User avatar
boeserbaer
Active Member
Posts: 51
Joined: Fri Jan 29, 2010 4:36 pm

Post by boeserbaer »

I don't know if what I did was correct, but I queued all communications in my communications thread (select on rex -> queue , default: -> remove from queue and send over channel).

This has solved my lockup when sending data from my comms thread to my other threads.

I definitely wish I knew what the rules were for when I can use a comms channel
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Post by paul »

Normal channels are synchronous - this means that there is a handshake to open a channel comm to another thread then it sends the data and then it closes the channel. This therefore means that the sender will hang until the receiver does an "in" on the channel.

If you want to avoid the handshake then you can use streaming channels (just declare channels and chanends with the "streaming" keyword). This still requires you to take data off the channel at the same rate you put it on (the channel only has a small 4 byte buffer) - but will not do the handshaking.

Hope that helps,
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.