Attached is a small program which compiles right but fails on execution with an exception ET_ILLEGAL_RESOURCE. The goal of this program is to have one thread (receiver) which handles an I/O port (here PORT_4A) and several other threads (senderX) which send "commands" to that thread, via one channel each.
If I use an array of chanend as argument to the first function and one array element per sender thread, I've got the exception. (see file chanarray.xc).
Code: Select all
void receiver(chanend c[NB_CHAN])
{
unsigned data;
while (1) {
select {
case (int i = 0; i < NB_CHAN; i++) c[i] :> data:
break;
}
myport <: data;
}
}
If I use a list of chanend for the receiver and one chanend per sender, the program works as expected. (see file chanlist.xc)Program received signal ET_ILLEGAL_RESOURCE, Resource not valid.
0x00010160 in sender1 (c=1026) at chanarray.xc:29
29 c <: 0x1;
Code: Select all
void receiver(chanend c1, chanend c2, chanend c3, chanend c4)
{
unsigned data;
while (1) {
select {
case c1 :> data: break;
case c2 :> data: break;
case c3 :> data: break;
case c4 :> data: break;
}
myport <: data;
}
}
Does anyone have any ideas?
Cheers,
Julien