XC 3.4 Transactions
Posted: Wed May 26, 2010 11:29 pm
Unfortunately Programming XC on XMOS Devices - section 3.4 seems FUBB, here are the examples for section:
This first example looks ok:
The second attempts to show how transactors work but is just wrong in so many ways
For the third example I have absolutely no idea what the frigg is going on, help me, please make it stop :?
Lets try to clear this up so newbies at least have a fighting chance at learning XC instead of bouncing of the walls..
This first example looks ok:
Code: Select all
# include < platform .h >
int snd [3] , rcv [3];
int main ( void ) {
chan c ;
par {
on stdcore [0] : master { // Thread X
for ( int i =0; i <10; i ++)
c <: snd [ i ];
}
on stdcore [1] : slave { // Thread Y
for ( int i =0; i <10; i ++)
c : > rcv [ i ];
} } }
Code: Select all
transaction inArray ( chanend c , int data [] , int size ) {
for ( int i =0; i < size ; i ++)
c : > data [ i ];
}
int main ( void ) {
chan c ;
int snd [3] , rcv [3];
par {
master inArray (c , rcv , 3);
slave {
for ( int i =0; i <10; i ++)
c : > rcv [ i ];
} } }
Code: Select all
select {
case slave { inArray ( c1 , packet , P_SIZE ); } :
process ( packet );
break ;
case slave { inArray ( c2 , packet , P_SIZE ); } :
process ( packet );
break ;
}