Underneath Xmos XS1 is a concurrent event driven system and is thus an ideal candidate for a CSP approach. This was similar for the Transputer decades ago. Then Occam, deriving from David's work based on Hoare's CSP was used to tame the concurrent beast underneath. Moving through the decades we see "C/C++" dominating the low level programming word, despite Occam's obvious advantage its a difficult pill for the electronics dev community to swallow given their immersion in C and C extensions like C++. Its difficult enough to sell a new idea like a Transputer or event driven concurrent multi core like Xmos XS1, thus why not extend something that is more familiar? Hence we have XC, C with extensions for event driven concurrent processing and that may well be the message that one should initially get, that makes the 'sell' easier today.
However, The truth is that the power of XC is found when one understands that it's 'a wolf in sheep's clothing' because underneath it really is CSP, it was always designed to be so because that is what is needed to provide safe concurrent event driven programming for Xmos XS1.
Lets look at XC's CSP:
Code: Select all
chan c;
par {
network1(c);
network2(c);
}
Already we see CSP basic ingredients fork join parallelism and channels to support communication between the concurrent processes, these are similar to Occam's PAR and CHANNEL identifiers. In Occam you also have SEQ for sequential rather than parallel but in our 'C' like XC, SEQ is implied as C is sequential by default.
Code: Select all
select
{
case : In when pinseq(0) :> x
process(x);
break;
case c :> command :
action(command);
break;
}
Here we see XC's select operating on ports and channels, the very stuff of CSP and a 'C' like interpretation (syntax?) from Occams ALT or Alternate identifier.
Both of these examples provide a peek at the real power under the bonnet for XC with XS1, this isn't just compensating for missing pointers - pass by reference and returning of tuples.
In reality XC's power only comes when you approach programming in a CSP rather than a 'C' like manner, if you keep thinking in 'C' you will not conquer XS1 you will be a slave to 'C'. Now don't get me wrong I love that you can drop down to C/C++ for performance or to use existing libraries, but that approach should not be used to solve issues with the XC language. XC isn't complete although it borrows a lot from Occam's CSP, it is missing certain functionality particularly the mobile concepts added by Milner which resulted in Occam being revised several times until its current carnation Occam-Pi. Milners work pointed out shortcomings of Hoare's CSP model and Added Pi Calculus into the mix, making Occam more complete. Thus I hope we will See
XCPi or
PiXC the addition of mobility and the channel strengthening from Protocols are IMHO required steps for XC to become complete, so that we don't have to drop down to using C pointers or C++ objects in order to make good structured programs.
Also I am trying to make some of this appear more 'C' like for example in protocols see my
comments
Also I have started to try and get some
CSP channel work across, take a look and let me know your thoughts, I hope to add more time permitting
If it helps rather than thinking of them as tuples think of them as anonymous structs, then its more 'C' like ;-)
P.S. We should all let some of the wolf out from under us OWOOHH...