On 13 June 2012 11:34, Øyvind Teig wrote:
> Thank you Rog! I am learning all the time!
> Now I am confused as to how much of your code I could adopt in my paper?
Feel free to use my code. It took 5 minutes to write - use it as you like.
> It will appear in the Appendix, as it really explains how Go may solve that
> problem by select in/out and no extra buffer process
I'm not sure what you mean here. There *is* an extra buffer process.
I am writing a paper for a conference trying to argue for a new channel type "XCHAN" (based on these ideas: http://oyvteig.blogspot.com/2011/12/034-output-guard-vs-channel-ready.html). But here is some paper Go that I would appreciate comments on.
This Go example uses blocking select (with no default case) with one output and one input. Line 10 attempts a blocking send (!) and line 14 attempts blocking receive (?). The select will block until the first component can execute. The top communication case is evaluated first, so sending takes priority if both are ready. In the receive statements of lines 14 and 21 we have dropped an optional second parameter, so we assume the channel does not become closed.
In Go we see that the problem in mind (with a faster Producer than Consumer) may be solved without any XCHAN or extra overflow buffer (as occam would). However, we assume that this is not what the Go designers would think as idiomatic Go.
If the receiver is not there, it tries to input (?) on the output channel but will block until the other side also inputs? Only then will it spool back again an then the send should succeed?
Is it possible to (fake) input on the sender end?
Or did I read Go syntax wrongly?
Being used to occam in the nineties this is new to me!
If so, it is interesting since I think this was the reason why the Ada rendezvous, also based on CSP, was banned for the Ada Ravenscar high integrity profile, where analyzability with respect to timing is important. A standard occam ALT or XC select (I believe) do not queue.
Also, will a zero-buffered Go chan also queue? Where do I find this information?
You are right about occam, I have also heard that story. The transputer links and channels routed via other processors seemingly made a complex protocol for output guards. I have heard that the ALT alone was 2 KB of microcode, eveb without the output.
But as far as I see, the new XC language by XMOS (David May is still around, slightly younger then me), XC too has no output guards. Please prove me wrong!
A Go "Ravenscar profile" would prohibit those Go queues! That's a nuisance, I would think..
case <- ch:
// no code
??
The channel seems to have a role between a "pure" CSP channel (blocking), an object (with operations), and a buffer (different usage, like the reading in the Send to take one out while trying to send)? Is such a description of any value?