Fair select Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
sirop
Junior Member
Posts: 5
Joined: Mon Oct 10, 2016 3:53 pm

Fair select

Post by sirop »

Hello.

http://www.xmos.com/download/private/AN ... rc4%29.pdf
says:
If a client sends a message while the server is handling a message for another client, the output statement in that client task will block.

I'd say if the output statement will block, that's is still better than if the output statement will get discarded.

My 2 questions are:
  1. Will the select get the output statement of the until then blocking client right after the select processed the event/output statement of another client?
  2. If so, does this behaviour is also to be expected regardless what kind of channel is used: either streaming or non-streaming?
Thanks.
View Solution
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Hi sirop,

Thanks for your questions. In answer to them:

1) The select in the server will get the output of one of the blocked clients as soon as it has finished handling a given client. The fair select loop ensures that it is not the same client it just serviced by temporarily disabling any client it services. The order in which other clients are serviced is not defined.

2) The behaviour of a streaming channel is very different in that the client will not block at the output statement unless the channel is full of data already. The channel on the other hand has a handshake protocol to ensure that the output does not complete until the server has consumed the data.

Regards,

Peter
User avatar
sirop
Junior Member
Posts: 5
Joined: Mon Oct 10, 2016 3:53 pm

Post by sirop »

Thanks for your answer.
peter wrote:Hi sirop,


2) The behaviour of a streaming channel is very different in that the client will not block at the output statement unless the channel is full of data already. The channel on the other hand has a handshake protocol to ensure that the output does not complete until the server has consumed the data.

Regards,

Peter
So if two clients use the same streaming channel to "speak" to the select function of a server,
and client 2 tries to send data while client 1 is sending data over the only streaming channel and has been already chosen by the select function of the server, will then the data of client 2 still be accepted by the server as soon as client 1 completed its data transmission?
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Hi sirop,

In xC, streaming channels are point-to-point. So, each client would have its own streaming channel end and the server has an array of streaming channel ends which it selects on. This means that it is not possible to have two clients sharing a streaming channel end to the server.

In the case where client 1 is streaming data to the server at the time that client 2 starts streaming data then the server will not respond to client 2 until it has finished with client 1, but no data will be lost. The server will receive all the data from client 2 once it starts to service it. Client 2 will be able to send as much data into the streaming channel as there is buffering in the channel (the amount of buffering depends on where the client/server are located in the system). Once the buffering is full then client 2 will block. But again, no data will be lost.

Regards,

Peter
User avatar
sirop
Junior Member
Posts: 5
Joined: Mon Oct 10, 2016 3:53 pm

Post by sirop »

peter wrote:Hi sirop,
In the case where client 1 is streaming data to the server at the time that client 2 starts streaming data then the server will not respond to client 2 until it has finished with client 1, but no data will be lost. The server will receive all the data from client 2 once it starts to service it. Client 2 will be able to send as much data into the streaming channel as there is buffering in the channel (the amount of buffering depends on where the client/server are located in the system). Once the buffering is full then client 2 will block. But again, no data will be lost.

Regards,

Peter
Yes, thanks, you cleared all details to me.