Need help with transactions

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
Primate
New User
Posts: 2
Joined: Mon Feb 15, 2010 7:58 pm

Need help with transactions

Post by Primate »

Hi all. I've run into a little problem with transaction that I hope you can help me with.

In my application I have eight "worker" threads that are split over two cores, a virtual ROM thread (32k bytes)
running on it's own core, and a manager thread running on a fourth core. Accessing the ROM was going
slower then I like so I tried implementing transactions for reading it, but I keep getting the following error:
Unhandled exception: ILLEGAL_RESOURCE, data: 0x00000102

The way I am doing my transaction is as follows:

Code: Select all

transaction read_rom( chanend _rom, uint data[], uint size )
{
   _rom <: ROM_READ;
   _rom <: size;

   for( uint i=0; i<size; i++ )
      _rom :> data[i];
}

void load_worker( chanend worker, chanend _rom )
{
   uint i;
   uint data[512];

   master read_rom( _rom, data, 512 );
   slave
   {
      worker <: WORKER_HALT;
      worker <: WORKER_LOAD;
      worker <: 512;

      for( i=0; i<512; i++ )
         worker <: data[i];

      worker <: WORKER_BEGIN;
   }
}

void worker_manager( chanend workers[8], chanend _rom )
{
   ...
   load_worker( workers[0], _rom );
   ...
   while( 1 )
   {
      ..
   }
}
After reading up on transactions a bit more, it seems that it's for one channel only and what i'm trying to do
is to synchronize two channels. Is there something I have missed or is there another way I can do this task
without use of streaming channels?

Any help is appreciated.
Thanks.


User avatar
monk_is_batman
Active Member
Posts: 38
Joined: Wed Jun 09, 2010 3:20 am
Location: Maine, USA

Post by monk_is_batman »

Can you post the slave section in your rom thread that handles opposite side of the read_rom function?
User avatar
Primate
New User
Posts: 2
Joined: Mon Feb 15, 2010 7:58 pm

Post by Primate »

See, I knew I was getting this wrong. I don't have one.
How would you construct this scenario above (without streaming channels)?
Or better yet, this is the flow im after:

Manager tells Worker to HALT
Manager requests 512 bytes from ROM (or any storage really)
Manager tells Worker to LOAD
Manager sends 512 bytes to Worker
Manager tells Worker to RUN

There is a few other stuff going on in there aswell, like the worker telling the manager it is complete
and such stuff, but i've commented out all those things in my code and they don't seem to affect the
outcome.

This is an easy thing to do with normal chanend's, but I was under the impression that I could speed
it up by using transactions so that the 512 byte transfer from ROM and into the worker thread would
not block the manager for a long time. The manager thread should only act as a proxy in this case.

Or, is it possible for me to somehow send a channel end through a channel? So that the manager thread
can send the ROM chanend into a worker, flag it as locked, and then the worker can read from ROM itself,
tell the manager it is done and "give back" the reference to it . I doubt that one though.